mysql数据库将文件内容加载到表中报错:

mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet
       LINES TERMINATED BY '\r\n';
ERROR 1148: The used command is not allowed with this MySQL version

 

原因:

涉及到数据库安全的问题,本地导入文件的参数没有打开。

 

解决方法:

  • 服务器端:
SHOW VARIABLES LIKE '%local%';

  得到  local_infile   OFF  即该变量未开启

SET GLOBAL local_infile=1;

MySQL8.0加载文件内容报错: ERROR 1148: The used command is not allowed with this MySQL version

  这时还是报错的~

 

  • 客户端:

  连接数据库时

mysql -u Name -p --local-infile=1;

MySQL8.0加载文件内容报错: ERROR 1148: The used command is not allowed with this MySQL version

 

 

注:这两步都需要执行喔!

 

另:以上是初学时不太严谨用的root用户,但是数据库一般使用普通用户,我参考此篇创建及授权的

https://www.cnblogs.com/sos-blue/p/6852945.html

以下为用普通用户导入的全过程

MySQL8.0加载文件内容报错: ERROR 1148: The used command is not allowed with this MySQL version

MySQL8.0加载文件内容报错: ERROR 1148: The used command is not allowed with this MySQL version

MySQL8.0加载文件内容报错: ERROR 1148: The used command is not allowed with this MySQL version

 

相关文章:

  • 2022-12-23
  • 2021-08-17
  • 2021-06-21
  • 2021-09-22
  • 2022-01-15
猜你喜欢
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-12-23
  • 2022-02-19
相关资源
相似解决方案