Windows sql语句正则匹配导出数据到本地 The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

尝试使用 into outfile导出数据的时候出现错误:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

方法一:查看本地允许导出目录

mysql>SHOW VARIABLES LIKE "secure_file_priv";

 C:ProgramDataMySQLMySQL Server 5.7Uploads 

mysql> select * from tncl where tncl_id regexp'^0065' into outfile 'C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\test123.csv';

方法二:自定义修改导出目录

问题是mysql设置的权限,可以使用

show variables like '%secure%';查看 secure-file-priv 当前的值是什么

导出的数据必须是这个值的指定路径才可以导出,默认有可能是NULL就代表禁止导出,所以需要设置一下

知道mysql安装路径下的my.ini文件,设置一下路径:

然后重启数据库即可;

原文地址:https://www.cnblogs.com/smuxiaolei/p/7483014.html