解决“MySQL server is running with the --secure-file-priv option so it cannot execute this statement”问题
二、解决方法1、使用show variables like '%secure%';命令查看secure-file-priv的值mysql> show variables like '%secure%';+------------------+-------+| Variable_name| Value |+------------------+-------+| secure_auth| O
二、解决方法
1、使用show variables like '%secure%';命令查看secure-file-priv的值
mysql> show variables like '%secure%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_auth | ON |
| secure_file_priv | NULL |
+------------------+-------+
2 rows in set (0.00 sec)
发现 secure_file_priv的值为null,表示禁止导出
2、进入到mysql安装目录,在my.cnf文件末尾添加以下部分:
secure_file_priv="/"
3、重启mysql
systemctl restart mysqld
4、使用root登录后再次报错
ERROR 13 (HY000): Can't get stat of '/home/lineitem.csv' (Errcode: 13 - Permission denied)
将LOAD DATA INFILE
换成
LOAD DATA LOCAL INFILE
OK!
原因分析:
出于安全原因,当读取位于服务器中的文本文件时, 文件必须位于数据库目录中,或者是全体可读的。另外,要对服务器文件使用LOAD DATA INFILE,您必须拥有FILE权限。
如果指定了LOCAL,则文件会被客户主机上的客户端读取,并被发送到服务器。文件会被给予一个完整的路径名称,以指定确切的位置。
参考连接:https://blog.csdn.net/zhuyunier/article/details/88707634
https://blog.csdn.net/weixin_39722921/article/details/113156666
更多推荐
所有评论(0)