MySQL【4】——MySQL导入本地文件

解决MySQL无法导入本地问文件的问题。

报错

could not run statement: Loading local data is disabled; this must be enabled on both the client and server sides

解决

  1. 登陆MySQL查看当前状态,在命令行输入:
SHOW GLOBAL VARIABLES LIKE 'local_infile';

OFF状态:

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | OFF    |
+---------------+-------+
1 row in set (0.00 sec)
  1. 启用全局本地数据加载功能,在命令行输入:
SET GLOBAL local_infile = 'ON';
SET GLOBAL local_infile = 1;
SET GLOBAL local_infile = true;
  1. 重新检查状态:
SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | ON    |
+---------------+-------+
1 row in set (0.01 sec)

注意,如果是重新启动MySQLsystemctl restart mysql还是会变更为OFF,只是退出MySQLexit;再登录不会变更。

参考资料

comments powered by Disqus