MySQL數據表導出某條記錄


請按照步驟導出,否則可能會報錯:

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

第一步:首先進入數據庫

mysql> show variables like '%secure%';
+--------------------------+-----------------------+
| Variable_name            | Value                 |
+--------------------------+-----------------------+
| require_secure_transport | OFF                   |
| secure_auth              | ON                    |
| secure_file_priv         | /var/lib/mysql-files/ |
+--------------------------+-----------------------+
3 rows in set (0.00 sec)

secure_file_priv為導出路徑,必須為這個,后邊加文件名;

第二步:導出

mysql> select idfa from firstapp_report where day_time between '2018-12-13 00:00:00.028986' and '2018-12-17 23:59:50.512468' into outfile '/var/lib/mysql-files/result.txt' lines terminated by '\r\n';;
Query OK, 86329 rows affected (0.09 sec)
into outfile “c:/data_out.txt” (輸出的文件路徑)
lines terminated by “\r\n” (每一行都換行)

第三步:進入導出的文件路徑

root@vmware01:/var/lib/mysql-files# ls
result.txt

 # 查詢某天的數據

select count(id) from firstapp_report where callback_result_text='success' and offer_id=25 and date_format(day_time,"%Y-%m-%d")="2018-12-18";

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM