MYSQL ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv
作者:
hbhe0316
1.mysql导出数据抛出错误:
mysql> select * INTO OUTFILE '/tmp/t2.txt' from testdb.t2;
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
查看官方文档,secure_file_priv参数用于限制LOAD DATA, SELECT …OUTFILE, LOAD_FILE()传到哪个指定目录。
secure_file_priv 为 NULL 时,表示限制mysqld不允许导入或导出。
secure_file_priv 为 /tmp 时,表示限制mysqld只能在/tmp目录中执行导入导出,其他目录不能执行。
secure_file_priv 没有值时,表示不限制mysqld在任意目录的导入导出。
mysql> show global variables like '%secure_file_priv%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | NULL |
+------------------+-------+
1 row in set (0.01 sec)
又因为 secure_file_priv 参数是只读参数,不能使用set global命令修改。
修改/etc/my.cnf文件
[root@mysql8 ~]# cat /etc/my.cnf | grep secure
secure_file_priv=''
重启mysql进程
[root@mysql8 ~]# service mysqld restart
Shutting down MySQL... SUCCESS!
Starting MySQL.. SUCCESS!
查看导出是否成功
mysql> select * INTO OUTFILE '/tmp/t2.txt' from testdb.t2;
Query OK, 10000000 rows affected (9.61 sec)
版权声明:本文为博主原创文章,未经博主允许不得转载。
mysql