环境说明:CentOS6.X+WDCPv3.0.8版本(lanmp)
错误原因:用户执行脚本报错。
错误内容为:
ERROR 1290 (HY000): The MySQL server is running with the –secure-file-priv option so it cannot execute this statement
用户脚本内容如下:
#!/bin/bash rm -rf /tmp/sleep_processes.txt mysql -hlocalhost -uroot -pwOCtXimmg6jiK3Wb -e "select concat('KILL ',id,';') from information_schema.processlist where Command = 'Sleep' AND user = 'root' into outfile '/tmp/sleep_processes.txt'" mysql -hlocalhost -uroot -pwOCtXimmg6jiK3Wb -e "source /tmp/sleep_processes.txt;" rm -rf /tmp/sleep_processes.txt
测试出错内容为执行该语句报错:
select concat('KILL ',id,';') from information_schema.processlist where Command = 'Sleep' AND user = 'root' into outfile '/tmp/sleep_processes.txt'
查询得知语句用途为结束长时间运行未结束的mysql进程,详细内容参见:http://www.cnblogs.com/siqi/p/3984499.html
输出错误为:
错误原因:
上网查了一下,使用 into outfile导出数据的时候出现错误:应该是mysql设置的权限,可以使用
show variables like '%secure%';查看 secure-file-priv 当前的值是什么。
如果 secure-file-priv 当前的值默认是NULL就代表禁止导出,所以需要设置一下。导出的数据必须是这个值的指定路径才可以正常导出。查看用户需要导出文件路径为:/tmp/sleep_processes.txt,所以这里需要设置的路径为/tmp/。
那在mysql的配置文件[mysqld]设置单元中添加设置,添加内容为:secure-file-priv=/tmp/ 。修改保存之后,重启mysql服务
再次测试结果如下:
测试正常,问题处理完毕
参考文章如下:
http://blog.csdn.net/learner_lps/article/details/65448098
http://blog.csdn.net/man_to_home/article/details/54947518