报错信息
执⾏类似于下列的语句时:
select ‘x’ into outfile ‘c:/www,txt’;
出现如下报错:
原因
mysql⽂件的导⼊和导出路径有默认的设置,即 secure-file-priv,当传⼊的csv⽂件路径与默认的路径冲突时就会报错。
secure-file-priv 的 值 有 三 种 情 况 : secure_file_prive=null ––限制mysqld 不允许导⼊导出
secure_file_priv=/path/ – —限制mysqld的导⼊导出只能发⽣在默认的/path/⽬录下
secure_file_priv=’’ – —不对mysqld 的导⼊ 导出做限制
解决⽅法
- 查看secure-file-priv设置
show variables like ‘%secure%’;
输出默认值path
- 找到名为my的配置设置⽂件:
- 加上在⾥⾯加上如下两⾏语句:
# Secure File Priv
secure-file-priv=""
保存后重启数据库。
- 此时即可成功执⾏写⼊⽂件的命令了