解决MySQL导入数据时遇到secure-file-priv的问题

血红的双手。 提交于 2020-05-01 06:27:39

使用以下mysql命令导入数据到mysql表时遇到

“MySQL server is running with the –secure-file-priv” Error

mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;

 

原因在于“secure_file_priv”这个设置的值,默认是NULL,这就禁止了我们导入数据。

使用 show variables like %secure% 可以查看“secure_file_priv”的默认配置。

 

MySQL官网对这个配置的说明

https://dev.mysql.com/doc/refman/8.0/en/option-files.html

 

 

在哪里去更改这个配置呢,请看mysql官网的答案

https://dev.mysql.com/doc/refman/8.0/en/option-files.html

 

因为我用的是docker mysql,所以我的这个配置在/etc/mysql/my.cnf

用vi或者vim打开/etc/mysql/my.cnf,可见它的默认值是NULL,把这个默认值改成上面官网里面的其它两个值之一就可以了。

 

然而,这并不能解决docker mysql的问题,之后导入数据时会报不支持此版本的问题。

so,果断放弃。

哪来这么麻烦,直接用navicate之类的客户端导入数据,完美解决。

 

参考链接:

secure_file_priv

https://computingforgeeks.com/how-to-solve-mysql-server-is-running-with-the-secure-file-priv-error/

 

start/stop/restart 启动 停止重启mysql的各种方法

https://coolestguidesontheplanet.com/start-stop-mysql-from-the-command-line-terminal-osx-linux/

 

MySQL官网 load date into table,这个有个用于示例的数据库表。

https://dev.mysql.com/doc/refman/8.0/en/loading-tables.html

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!