Windows10 MySQL5.7.21.0 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p解决办法

在《MySQL从入门到精通》例14.10题,有 SELECT * FROM test.person INTO OUTFILE "C:/person0.txt"; 这样一个导出语句。如果直接写到MySQL中,会报错 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p 。 

Windows10 MySQL5.7.21.0 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p解决办法

通过使用 show variables like '%secure_file_priv%'; 语句,发现MySQL要求导出文件必须在 C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\ 下。

Windows10 MySQL5.7.21.0 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p解决办法

如果直接把导出语句修改为SELECT * FROM test.person INTO OUTFILE "C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\person0.txt"; ,则会继续报错 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p 。

经查明,MySQL5.7.21.0是不认识 \ 反斜杠,只支持 / 正斜杠。因此要把 C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\  修改为 C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/ 。完整的语句为 SELECT * FROM test.person INTO OUTFILE "C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/person0.txt"; 

Windows10 MySQL5.7.21.0 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p解决办法

然后在 C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\ 文件夹下查看,就会看到 person0.txt

Windows10 MySQL5.7.21.0 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p解决办法


Windows10 MySQL5.7.21.0 ERROR 1290 (HY000): The MySQL server is running with the --secure-file-p解决办法


网络上的修改my.ini文件的方法,我一直没有成功,可能是技术水平有限。