Mysql 1290 - The MySQL server is running with the --secure-file-priv option

问题场景

执行导入数据报错

执行语句如下:

load data infile 'C:\Users\86183\Desktop\laodInFile.txt' INTO TABLE test.test1;

报错信息如下:

1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

问题原因

由于secure-file-priv变量的默认设置为/var/lib/mysql-files/所引起的,该值意味着只能导出到指定目录下(已验证),否则会报错,查看mysql数据库该变量值:

show variables like '%secure%';

分析原因

secure-file-priv 配置值详解:

(1)secure_file_prive=null,限制mysqld 不允许导入导出

(2)secure_file_priv=/var/lib/mysql-files/,限制mysqld的导入导出只能发生在/var/lib/mysql-files/目录下

(3)secure_file_priv=' ',不对mysqld的导入导出做限制

解决办法

(1)修改 secure_file_prive 的变量值即可。

打开my.cnf 或 my.ini 文件

secure_file_priv = ''

(2)重启 Mysql 服务

(3)查看变量值

(4)再次执行导入语句,即可成功执行。

猜你喜欢

转载自blog.csdn.net/weixin_36754290/article/details/129267205