打开网站显示The MySQL server is running with the --secure-file-priv option so it cannot execute this statement错误怎么办|已解决

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

 
问题:执行 LOAD DATA INFILE/SELECT ... INTO OUTFILE 时提示因 secure-file-priv 配置无法执行
 
原因:MySQL 的 secure-file-priv 参数限制了导入导出文件的目录,指定的文件路径不在允许范围内
 
解决方案:
1. 执行 SHOW VARIABLES LIKE 'secure_file_priv'; 查看允许的目录;
2. 将文件放到该目录下再执行导入导出;
3. 修改 my.cnf 添加 secure-file-priv=/自定义目录(重启服务生效),或设为 secure-file-priv='' 取消限制(不建议生产环境)
posted @ 2026-03-18 10:37  可有仙子迎风立  阅读(40)  评论(0)    收藏  举报