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

解决方法

一:报错:

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

 

二:分析:

MySQL 对于导入导出的目录是有限制的,只允许指定的目录才能导入导出。

secure_file_priv 这个变量被用于限制导入和导出的数据目录,比如 LOAD DATA 和 SELECT ... INTO OUTFILE 语句,以及 LOAD_FILE() 函数。这些操作限制了哪些用户拥有文件操作权限。secure_file_priv 有些设置选项:

1).如果为空,不做目录限制,即任何目录均可以。

2).如果指定了目录,MySQL 会限制只能从该目录导入、或导出到该目录。目录必须已存在,MySQL 不会自动创建该目录。

3).如果设置为 NULL,MySQL 服务器禁止导入与导出功能。

查看允许的目录

/

mysql> show variables like "secure_file_priv"G

*************************** 1. row ***************************

Variable_name: secure_file_priv

        Value: /var/lib/mysql-files/

1 row in set (0.00 sec)

 

 

三:修改方法

修改 my.cnf 文件,在 [mysqld] 块下,如果没有 secure_file_priv 则新增

指定目录:secure_file_priv=/path/to/data

不限目录:secure_file_priv=

禁止操作:secure_file_priv=NULL

重启mysql.

你可能感兴趣的