Mac OS High Sierra + MySQL 8.0.12
尝试Load Data infile时候,总会报错:The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.
网上看了很多的解决办法,都没有解决。
最后发现配置my.cnf后有一项chmod漏掉了... chmod后解决,经验分享:
-
1. 打开终端 sudo vim /etc/my.cnf
-
2. 在[mysqld] section中加入secure_file_priv =
-
3. 保存my.cnf
-
4. sudo chmod 644 /etc/my.cnf
解释一下:因为你编辑了my.cnf,my.cnf的读写执行权限就发生了改变,mysqld会识别my.cnf被编辑而忽略my.cnf! 将my.cnf改回644就好了,也就是-rw-r--r--
-
5. 系统偏好设置中重启MySQL
-
6. 重新打开终端mysql -u root
-
7. show variables like '%priv%'; 看看secure_file_priv的值是不是变成nothing了
-
8. 哈哈 开始load file吧,enjoy!