mysql --secure_file_priv的设置

最近常需要将大表导出为csv格式,在使用select * into outfile xxx的时候,就会出现此报错。
 

[Code: 1290, SQL State: HY000] The MySQL server is running with the –secure-file-priv option so it cannot execute this statement

 
这时候可以先检查这个参数的值,在mysql数据库中输入以下命令:

show variables like ‘%secure_file_priv%’;

 
然后就可以看到:
 

默认的路径是/var/lib/mysql-files

如果要想修改此路径的话,只能通过修改启动时添加特定参数或者修改配置文件后重启服务来实现。

  1. 启动时添加特定参数。可通过mysqld -secure-file-priv=xxx来实现。
     

  2. 修改配置文件后重启。可以在mysql配置文件中mysqld选项下添加参数**secure-file-priv来实现。

 
其中,如果:
secure_file_priv=null 不允许csv文件的导入导出
 
secure_file_priv=xxx csv文件导入导出到某路径
 
secure_file_priv=/ csv文件可导入到任意路径

猜你喜欢

转载自www.cnblogs.com/young233/p/12469780.html
今日推荐