Create a data table
<span style= "FONT-SIZE:18PX;" >create TABLE weblogs ( MD5 varchar), URL varchar (+), request_date date, request_time Time, IP varchar ()) </span>
My version is: Server Version:5.5.38-0ubuntu0.12.04.1-log (Ubuntu)
An error will be given when importing with the following command:
<span style= "FONT-SIZE:18PX;" >mysql> LOAD DATA LOCAL INFILE '/home/hadoop/weblog_entries.txt ' into table weblogs fields TERMINATED by ' \ t ' LI NES TERMINATED by ' \ n '; ERROR 1148 (42000): The used command isn't allowed with this MySQL version</span>
Tip This version of MySQL does not support this import
Workaround: 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>-penter password:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 45Server version:5.5.38-0ubuntu0.12.04.1-log (Ubuntu) Copyright (c) #, Oracle a nd/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. 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 namesyou can turn off this feature to get a quicker startup W Ith-adatabase changedmysql> <span style= "color: #FF0000;" >load DATA LOCAL INFILE '/home/hadoop/weblog_entries.txt ' into table weblogs fields TERMINATED by ' \ t ' LINES TERMINATE D by ' \ n ' </span>; Query OK, up to rows affected (1.17 sec) Records:3000 deleted:0 skipped:0 warnings:0</span>
When you connect to MySQL, add--local-infile parameters and import them.
Or use the following method:
<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 tab Le weblogs fields TERMINATED by ' \ t ' LINES TERMINATED by ' \ n ' </span>
Cause analysis: According to the official explanation is that MySQL at compile time by default the local-infile parameter set to 0, is to shut down the function from the local load, so if you need to use only self-opening through the link when the parameter set to 1 the way
In addition, the following line breaks in Windows are not the same as Linux.
Windows line wrapping is \ r \ n, hexadecimal value is: 0D0A.
Linux line break is \ n, hexadecimal value is: 0A
MySQL load read from file to data tip error 1148