1、報錯信息
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
2、 報錯原因: mysql文件的導入和導出路徑有默認的設置,即 secure-file-priv,當傳入的csv文件路徑與默認的路徑衝突時就會報錯。
secure-file-priv的值有三種情況:
secure_file_prive=null ---限制mysqld 不允許導入導出
secure_file_priv=/path/ ---限制mysqld的導入導出只能發生在默認的/path/目錄下
secure_file_priv=' ' ---不對mysqld 的導入 導出做限制
3、 查看secure-file-priv設置
mysql> show variables like '%secure%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | NULL |
+--------------------------+-------+
4、修改配置
從上面可以看到默認的配置時限制導入導出的,直接在mysql中執行命令,把限制設置爲空,但是有報錯:
mysql> set global secure_file_priv='';
ERROR 1238 (HY000): Variable 'secure_file_priv' is a read only variable
這是因爲這個是隻讀參數,所以只能修改配置文件,然後重啓服務去做修改
修改配置文件
vim /etc/my.cnf
[mysqld]
# 設置爲空
secure_file_priv = ''
或者
# 設置導入導出的目錄
secure_file_priv = /data/file
重啓mysql,之後查看是否生效。