MySQL 报错Error Code: 1290. The MySQL server is running with the --secure-file-priv option

问题描述

在MySQL执行以下语句时弹出错误提示:

use jxgl;
lock tables course read;
select * into outfile 'course.bak' from course;
unlock tables;

错误提示:

Error Code: 1290. The MySQL server is running with the --secure-file-priv option  so it cannot execute this statement

根据错误找了相关资料,发现是secure-file-priv会指定文件夹作为导出文件存放的地方,那我们可以先找出这个文件夹。
在MySQL命令行界面输入一下指令:

show variables like '%secure%';

我们可以看到如下结果:
MySQL 报错Error Code: 1290. The MySQL server is running with the --secure-file-priv option_第1张图片
标注出来的即是正确的文件路径,我们将导出文件放在该目录下即可。
对于上述SQL指令,修改如下:

use jxgl;
lock tables course read;
select * into outfile 'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/course.bak' from course;
unlock tables;

这样就可以将数据导出到对应文件夹下,到处成功后可以在对应文件夹下看到导出文件。
MySQL 报错Error Code: 1290. The MySQL server is running with the --secure-file-priv option_第2张图片
这样就可以解决该问题了:)

你可能感兴趣的:(数据库)