在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 變量名 = ' 字符編碼 '