mysql导入.csv文件出错

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,之后查看是否生效。
posted @ 2019-11-12 17:58  断臂人123  阅读(1142)  评论(0编辑  收藏  举报