20230522-MySQL ERROR 1290 错误解决

在这里插入图片描述

操作:

select * from cjc.t1 into outfile '/home/mysql/t1_xxx.csv';

报错:

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

原因:

–secure-file-priv参数设置问题。

解决方案:

调整–secure-file-priv参数,建议改成指定目录

注意事项:
–secure-file-priv为只读参数,不支持在线修改,修改后重启数据库生效。

测试:

测试1:secure-file-priv=''和secure-file-priv=时,无限制,任何目录都可以导出

[mysql@cjc-db-03 13309]$ cat my.cnf |grep secure
secure-file-priv=''

mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_file_priv |       |
+------------------+-------+
1 row in set (0.01 sec)

mysql> select * from cjc.t1 into outfile '/home/mysql/t1_xxx.csv';
Query OK, 3 rows affected (0.00 sec)

[mysql@cjc-db-03 13309]$ cat my.cnf |grep secure
secure-file-priv=

mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_file_priv |       |
+------------------+-------+
1 row in set (0.02 sec)

mysql> select * from cjc.t1 into outfile '/home/mysql/t2_xxx.csv';
Query OK, 3 rows affected (0.05 sec)

测试2:secure-file-priv=NULL时,无权限,任何目录都不能导出

[mysql@cjc-db-03 13309]$ cat my.cnf |grep secure
secure-file-priv=NULL

mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_file_priv | NULL  |
+------------------+-------+
1 row in set (0.01 sec)

mysql> select * from cjc.t1 into outfile '/home/mysql/t2_xxx.csv';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

测试3:secure-file-priv=指定路径 时,指定路径有导出权限,其他目录不能导出

[mysql@cjc-db-03 13309]$ cat my.cnf |grep secure
secure-file-priv='/home/mysql/tmp'

mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+------------------+
| Variable_name    | Value            |
+------------------+------------------+
| secure_file_priv | /home/mysql/tmp/ |
+------------------+------------------+
1 row in set (0.01 sec)

mysql> select * from cjc.t1 into outfile '/home/mysql/t3_xxx.csv';
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

mysql> select * from cjc.t1 into outfile '/home/mysql/tmp/t3_xxx.csv';
Query OK, 3 rows affected (0.00 sec)

mysql> system cat /home/mysql/tmp/t3_xxx.csv
3
2
1

###chenjuchao 20230522###
欢迎关注我的公众号《IT小Chen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值