MySQL 导入文件数据(且解决 ERROR 1148 (42000): The used command is not allowed with this MySQL version)

1. mysql 语句

LOAD DATA LOCAL INFILE "xxx/xxx/xxx.xxx" INTO TABLE `xxx`.`xxx`;

报错
ERROR 1148 (42000): The used command is not allowed with this MySQL version

2. 解决错误

2.1 改表

local_infile 中的 值从 off 改为 ON

/* 查看 local_infile */
show global variables like 'local_infile';

/* off 改为 ON */
set global local_infile = 'ON';

再次查看结果

在这里插入图片描述

2.2 从新登入 MySQL

退出

/* 退出 mysql */
\q

从新登入

/* 登入 mysql */
mysql --local-infile=1 -u root -p

按上面从新登录在执行 MySQL 导入文件数据的语句

3. 进阶

LOAD DATA LOCAL INFILE "xxx/xxx/xxx.xxx" INTO TABLE `xxx`.`xxx` fields terminated by 'xx' optionally enclosed by 'xx' lines terminated by 'xx';

	1. LOAD DATA LOCAL INFILE "xxx\xxx\xxx.xxx": 导入数据的文件名路径加上文件名.
	2. INTO TABLE `xxx`.`xxx`: 导入数据到那个数据库中的那个表.
	3. fields terminated by 'xx': 以 xx 为分隔符.
	4. optionally enclosed by 'xx': 去掉包围字段内容的 xx.
	5. lines terminated by 'xx': 以 xx 为行尾符.
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值