The error "ERROR1148" is returned when MySQLload reads data from a file.

Source: Internet
Author: User
The error "ERROR1148" is returned when MySQLload reads data from a file.

When MySQL load reads data from a file, ERROR 1148 is displayed.

Create a data table in MySQL

Create table weblogs (
Md5 varchar (32 ),
Url varchar (64 ),
Request_date date,
Request_time time,
Ip varchar (15 ))

My version is: Server version: 5.5.38-0Ubuntu0. 12.04.1-log (Ubuntu)

When you use the following command to import data, an error is returned:

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

It is prompted that mysql of this version does not support such import.

Solution:

Hadoop @:~ $ Mysql-uroot -- local-infile = 1-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,201 4, 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-

Database changed
Mysql> load data local infile '/home/hadoop/weblog_entries.txt' INTO table weblogs fields terminated by '\ t' lines terminated by' \ n ';
Query OK, 3000 rows affected (1.17 sec)
Records: 3000 Deleted: 0 Skipped: 0 Warnings: 0

Add the -- local-infile parameter when connecting to mysql and then import it.

Alternatively, use the following method:

Mysql-u [youruser]-h [youraddress]-p [yourpassword] [yourdatabase] -- local-infile = 1-e "[yourcmd]"

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 '\ N '"

Cause Analysis: according to the official explanation, mysql sets the local-infile parameter to 0 by default during compilation, that is, the local load function is disabled, therefore, if you need to use the method of setting this parameter to 1 when you can only open the link by yourself

In addition, line breaks in Windows are different from those in linux.

Windows newline is \ r \ n, and The hexadecimal value is 0D0A.

Linux line feed is \ n, and The hexadecimal value is: 0A

-------------------------------------- Split line --------------------------------------

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.