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);



Posted

in

by

Comments

Leave a Reply

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