导出报错
mysql> select * from test into outfile '/tmp/test.txt' fields terminated by ',' enclosed by '"' lines terminated by '\r\n';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
跟secure-file-priv参数有关,如果是null则不能导出到任何目录
mysql> show variables like '%secure%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | NULL |
设置成空值,就可以导出到任何目录了。改secure-file-priv参数需要重启数据库
1.修改cnf中的参数
[root@lzl ~]# cat /etc/my.cnf|grep secure
secure-file-priv=
2 重启mysqld
mysqladmin shutdown -S/tmp/mysql.sock -uroot -poracle
mysqld_safe --defaults-file=/etc/my.cnf &
检查是否生效
mysql> show variables like '%secure%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | |
+--------------------------+-------+
mysql> select * from test into outfile '/tmp/test.txt' fields terminated by ',' enclosed by '"' lines terminated by '\r\n';
Query OK, 4 rows affected (0.00 sec)