MySql Bulk Upload Command Line Tool

Does MySql have a bulk-loading command-line tool like bcp for SQLServer and sqlldr for Oracle? I know that there is an SQL LOAD INFILE or similar LOAD INFILE , but sometimes I have to upload a file located in another block to the MySQL database.

+7
sql mysql bulkinsert load-data-infile
source share
4 answers

mysqlimport.

accepts the same connection parameters as the mysql command-line shell. Be sure to use the -L flag to use the file on the local file system, otherwise it (oddly enough) will assume that the file is on the server.

There is also a similar version of the load data infile command, i.e. load data local infile , according to which the file will be downloaded from the client, and not from the server, which can accomplish what you want to do.

+7
source share
 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); 
+5
source share

I think mysqlimport can help?

Loads tables from text files in various formats. The base name of the text file should be the name of the table to be used. If you use sockets to connect to the MySQL server, the server will open and read the text file directly. In other cases, the client will open the text file. To import rows, use the SQL command "LOAD DATA INFILE".

+2
source share
 mysql -u root -p use database; source /path/yourfile.sql 

Perhaps you want to use rsync via ssh to transfer the β€œbulk file” from your computer to another.

+2
source share

All Articles