MySQL can read fixed-width and de-limited files directly using the LOAD DATA INFILE command. The LOAD DATA INFILE command can be used to read data files located on either the server or the client (with the LOAD DATA LOCAL INFILE syntax), using any delimiters you specify or fixed-width.
The full syntax of LOAD DATA INFILE is available here. This is one example of reading a comma-delimited file:
LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY 'n';
LOAD DATA INFILE is generally quite fast. In my experience, I have seen it load three million rows in roughly ten seconds.
This was first published in May 2006