在Mysql中把查询结果输出到文件中,我所经历的故事。javascript
Mysql 官方文档参考 http://tool.oschina.net/uploads/apidocs/mysql-5.5-en/sql-syntax.html#select-into html
个人输入java
SELECT * FROM tableName WHERE 条件 INTO OUTFILE '123abc.txt';
以上运行时报错。
[Err] 1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
参考网站:http://stackoverflow.com/questions/31951468/error-code-1290-the-mysql-server-is-running-with-the-secure-file-priv-option
运行语句
show variables like 'secure%';
图1. SQL语句运行截图
SELECT * FROM eid.eid_do_fields WHERE DOID = 'DEMO_BOMDO' INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/123abc.txt';
注:mysql中一个“/”表明求余的操做,若是你非要使用反斜杠,能够使用两个“//”mysql
图2, 处处 xls 文件中文乱码截图
图3,使用Atom打开123abc.txt与123abc.xls文件sql
show variables like 'char%';
图4. 数据库编码的相关信息数据库
set 变量名 = ' 字符编码 '