Categories
MySQL

Importing a CSV file into a table in MySQL

Here’s how you would import data into MySQL using a query

/*
If the CSV file was created in Windows, then replace '\n' with '\r\n' 
*/
LOAD DATA LOCAL INFILE '/path/to/csv_file.csv' INTO TABLE `table_name`
FIELDS TERMINATED BY ',' 
OPTIONALLY ENCLOSED BY "\"" 
LINES TERMINATED BY '\n' 
(field1, field2, field3);


By Moazzam

Moazzam is a software developer working in the big apple. He has over a decade of experience in development. While most of his work involves developing web applications, he does development for Android and Windows Mobile in his spare time.

Leave a Reply

Your email address will not be published. Required fields are marked *