MySQL 查询结果写入文件 标准码农 技术分享 283 views [https://dev.mysql.com/doc/refman/8.0/en/select-into.html](https://dev.mysql.com/doc/refman/8.0/en/select-into.html) [https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_secure_file_priv](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_secure_file_priv) ``` # my.cnf secure_file_priv=/Users/admin/Downloads/mysql ``` ```sql select * from t into outfile '/Users/admin/Downloads/mysql/data.csv' character set gbk FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'; ``` chmod 777 /Users/admin/Downloads/mysql 帮助PHPZlc项目! 与任何开源项目一样, 贡献代码 或 文档 是最常见的帮助方式, 但我们也有广泛的 赞助机会。 1 加入技术群 评论 去登录