问题现象:
完整的报错信息:[HY000][1290] The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
原因:
安装MySQL的时候限制了导入与导出的目录权限
补充说明:但如果用命令行导入,还是得将要导入的数据文件放到安全目录下
2022/05/08补充
查看secure_file_priv该变量的设置:
step1:打开MySQL终端MySQL 8.0 Command Line Client,输入如下命令:
SHOW GLOBAL VARIABLES LIKE '%secure%';
以这台电脑为例,目录 C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\就是导入导出的目录
解决办法:
找到配置文件my.ini,修改为不对导入导出目录做限制
对应的修改语句:
secure_file_priv=''
重启MySQL服务,问题解决。
【补充】my.ini文件的位置:
也是比较重要的一点,my.ini文件的位置,我找了多篇博客才找到我的my.ini文件(真是隐藏得深
打开MySQL终端MySQL 8.0 Command Line Client,输入如下命令:
select @@datadir;
参考博客:
mysql导入数据报错ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it
mysql 查找配置文件 my.ini 位置方法