mysql load 从文件读入数据提示ERROR 1148

创建数据表

<span style="font-size:18px;">CREATE TABLE weblogs(
            md5  varchar(32),
            url varchar(64),
            request_date date,
            request_time time,
            ip varchar(15))
</span>

我的版本是:Server version: 5.5.38-0ubuntu0.12.04.1-log (Ubuntu)

在使用如下命令导入时会报错:

<span style="font-size:18px;">mysql> LOAD  DATA LOCAL INFILE '/home/hadoop/weblog_entries.txt' INTO table weblogs FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
ERROR 1148 (42000): The used command is not allowed with this MySQL version
</span>

提示这个版本的mysql不支持这样导入

解决办法:http://dev.mysql.com/doc/refman/5.5/en/load-data-local.html

<span style="font-size:18px;">[email protected]:~$ mysql -uroot<span style="background-color: rgb(255, 0, 0);"> --local-infile=1</span>  -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 45
Server version: 5.5.38-0ubuntu0.12.04.1-log (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use realworld;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> <span style="color:#FF0000;">LOAD  DATA LOCAL INFILE '/home/hadoop/weblog_entries.txt' INTO table weblogs FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'</span>;
Query OK, 3000 rows affected (1.17 sec)
Records: 3000  Deleted: 0  Skipped: 0  Warnings: 0
</span>

在连接mysql的时候加上--local-infile的参数 然后导入即可

或者使用如下方式:

<span style="font-size:18px;">mysql -u [youruser] -h [youraddress] -p [yourpassword] [yourdatabase] --local-infile=1 -e "[yourcmd]" </span>
<span style="font-size:18px;">mysql -uroot -p123456 realworld --local-infile=1 -e "LOAD DATA local INFILE '/home/hadoop/weblog_entries.txt' INTO table weblogs FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'"</span>

原因分析:根据官方的解释是mysql在编译的时候默认把local-infile的参数设为0,就是关闭了从本地load的功能,所以如果需要使用只能自己打开 通过链接的时候把该参数设置为1的方式

另外windows下面的换行符和linux的是不一样的

windows换行是\r\n,十六进制数值是:0D0A。

LINUX换行是\n,十六进制数值是:0A

时间: 2024-08-27 16:19:04

mysql load 从文件读入数据提示ERROR 1148的相关文章

mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than &#39;max_allowed_packet&#39; bytes”解决办法

向mysql数据库中导入sql文件时,如果文件过大(几百M),会提示"Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes" 1.查看目前数据库配置 show VARIABLES like '%max_allowed_packet%'; 显示如下结果 +--------------------+---------+ | Variable_name      | Value   | +--------

mysql load本地文件失败,提示access denied

mysql load本地文件失败,提示access denied 解决方式 直接谷歌到stackoverflow,解决方式如下 mysql -u myuser -p --local-infile somedatabase 参考 https://stackoverflow.com/questions/18437689/error-1148-the-used-command-is-not-allowed-with-this-mysql-version?answertab=active#tab-top

对express中引入文件时提示Error: Cannot find module错误的理解

打算写个小demo,在引入一个routes文件时,一直提示Error: Cannot find module('./routes')的错误,经过一番了解. 如果要把整个文件夹下所有的模块都引进来  var routes = require('./routes')这时express会默认的去读取文件下的index.js文件,所以文件夹下所有的模块只需在index.js声明即可. 例如: 在routes文件下有user.js.count.js.index.js文件, 只需在index.js中 exp

【mysql】 load local data infield 报错 ERROR 1148 (42000): The used command is not allowed with this MySQL version

mysql> load data local infile '/Users/flint/learn/mysql/pet' into table bx_pet; 执行报错 ERROR 1148 (42000): The used command is not allowed with this MySQL version 解决办法: 在连接数据库的时候使用 mysql --local-infile -uroot -p 连接即可 原文地址:https://www.cnblogs.com/china-

mysql更改数据库目录提示“ERROR 2002 (HY000): &#39;/var/lib/mysql/mysql.sock&#39; (2)”

操作系统环境如下: [[email protected] data]# cat /etc/issue CentOS release 6.7 (Final) Kernel \r on an \m [[email protected] data]# uname -r 3.19.0-25-generic [[email protected] data]# getconf LONG_BIT 64 mysql数据库由于yum安装方式,所以默认的数据库目录是/var/lib/mysql,也就是my.cnf文

启动Mysql时,提示error 2002 的解决办法

故障描述 启动时提示ERROR 2002(HY000) 启动服务时,提示the server quit without updating PID file. 解决方法一: 1.由于mysql是卸载后重装的,查看日志文件发现端口3306被占用. 2.查看哪个进程占用,把进程结束掉,重启服务. # lsof -i :3306 # kill -9 4420  #4420为占用3306端口的进程号 # service mysqld start 若还有其他方法,欢迎评论补充

mysql登陆提示ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO

今天安装zabbix,安装完成之后在最上面提示如下所示 检查日志如下显示 显示连接数据库失败,登录mysql给zabbix授权之后发现zabbix彻底起不来了 数据库也登陆不进去,提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 数据库拒绝了root登录,于是先跳过受权表访问,命令如下:mysqld_safe --user=mysql --skip-grant-tables -

10.29 工作笔记 ndk编译C++,提示找不到头文件(ndk-build error: string: No such file or directory)

ndk编译C++.提示找不到头文件(ndk-build error: string: No such file or directory) 被这个问题弄得愁眉苦脸啊.心想为啥一个string都找不到呢..于是百度到了. . . 遇到这个问题,就在所在的文件夹 Application.mk 文件里.加入: APP_STL := gnustl_static 就能够找到标准库了! 最后知道真相的我.眼泪掉下来啊!

AndroidStudio解决提示:Failed to load AppCompat ActionBar with unknown error

Android Studio 3.1.4 问题:新项目建立时,layout下的xml项目出现Render problem - Failed to load AppCompat ActionBar with unknown error. 解决方案: 1.找到项目目录下的app\values\styles.xml文件,双击打开 2.将该文件下的代码段: <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActi