The method of data import is implemented in MySQL using the load data command
- 2020-05-30 21:12:52
The usage is as follows:
mysql>load data local infile "D:/ab.txt" into table mytbl(name,age);
Use the above command to import the contents of the D:/ ab.txt file into the table mytbl, where name and age are the fields of the table mytbl, corresponding to the data of each line in the ab.txt file. If not specified when compiling and installing mysql
The following error will be reported when using the above command:
ERROR 1148 (42000): The used command is not allowed with this MySQL version
There are two solutions, 1 is to recompile the installation with the above parameters, but directly use the command line, as follows:
mysql -uroot -proot mydb_name --local-infile=1 -e 'load data local infile "D:/ab.txt" into table mytbl(name,age)'
After testing 1, when importing 3 million pieces of data, the time of using the load data command is about 3 minutes, which is quite good!