MySQL 不允许向 secure_file_priv 意外的目录导出文件。
mysql> SELECT * FROM `order` INTO OUTFILE '/tmp/order.txt'; 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) mysql> SELECT * FROM `order` INTO OUTFILE '/var/lib/mysql-files/order.txt'; Query OK, 3 rows affected (0.00 sec) root@netkiller ~ % cat /var/lib/mysql-files/order.txt 1 Tom 22 2017-11-16 17:23:15 2 Neo 34.65 2017-11-16 17:29:28 3 Cici 34.98 2017-11-16 17:30:29
在 my.cnf 中 加入 secure-file-priv=/tmp 可以修改为你需要的目录。
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。