MYSQL导出数据报错”ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement”
root@localhost [team]>select * from team.player into outfile "/tmp/sql/player.txt";
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
通过报错的提示可以发现是由于secure-file-priv变量的设置所引起的,查看该变量的设置,默认的路径是/var/lib/mysql-files/
root@localhost [team]>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.01 sec)
说明:
secure_file_prive=null 限制mysqld 不允许导入导出
secure_file_priv=/var/lib/mysql-files/ 限制mysqld的导入导出只能发生在/var/lib/mysql-files/目录下
secure_file_priv=' ' 不对mysqld的导入导出做限制
解决方法:
修改secure_file_prive的值或者是按照默认的路径进行导出;
windows下在my.ini文件 [mysqld]节点 下添加secure_file_priv='',然后重启mysql服务。linux下 在 /etc/my.cnf中添加secure_file_priv=''。
1、我选择前者修改默认的路径
[root@seiang mysql]# vim /etc/my.cnf
[mysqld]
secure_file_priv=''
2、重新启动mysql服务
[root@seiang mysql]# systemctl restart mysqld.service
3、再次查看该变量取值为NULL
root@localhost [team]>show variables like '%secure%';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2
Current database: team
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | |
+--------------------------+-------+
3 rows in set (0.13 sec)
4、再次执行导出操作,成功
root@localhost [team]>select * from team.player into outfile "/tmp/player.txt";
Query OK, 3 rows affected (0.00 sec)
作者:SEian.G(苦练七十二变,笑对八十一难)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31015730/viewspace-2152273/ ,如需转载,请注明出处,否则将追究法律责任。