MySQL Import From Txt File with Large Filesize



This evening I would share a query that handle big size import from .txt file into table in MySQL v5.7 database. This file has 1.5 GB filesize and 13.687.653 rows.


Run this query.

$ LOAD DATA LOCAL INFILE 'C:\\Users\\Administrator\\Downloads\\file_example.txt' INTO TABLE tbl_example FIELDS TERMINATED BY '#' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;


Note: I would ignore line 1 because line 1 as fields name, and MySQL will read the data source starts from line 2.


If you are get warning message.

$ show warnings;

It will line number of data source error (incompatible row).


Source :

https://stackoverflow.com/questions/13579810/how-to-import-data-from-text-file-to-mysql-database

https://stackoverflow.com/questions/1215692/how-do-i-show-a-mysql-warning-that-just-happened

Comments