Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql bulk load command line tool

Does MySql have a bulk load command line tool like bcp for SQLServer and sqlldr for Oracle? I know there's a SQL command LOAD INFILE or similar but I sometimes need to bulk load a file that is on a different box to the MySQL database.

like image 419
Mike Q Avatar asked Oct 26 '09 17:10

Mike Q


2 Answers

mysqlimport.

takes the same connection parameters as the mysql command line shell. Make sure to use the -L flag to use a file on the local file system, otherwise it will (strangely) assume the file is on the server.

There is also an analogous variant to the load data infile command, i.e., load data local infile, according to which the file will be loaded from the client rather than the server, which may accomplish what you want to do.

like image 150
ʞɔıu Avatar answered Sep 18 '22 12:09

ʞɔıu


LOAD DATA LOCAL INFILE 'C:\\path\\to\\windows\\file.CSV'
INTO TABLE table_name
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, field2, field3, fieldx);
like image 37
Phill Pafford Avatar answered Sep 18 '22 12:09

Phill Pafford