MySQL: Import CSV data

There are a few ways to to it. Here’s a solution using load data:

load data local infile '/path/to/csvfile'
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
[ignore 1 lines]
[(column_1, @dummy, column_2,...)]


  • Line 5: Optional. This will ignore the 1st line in CSV file if that’s a header row.
  • line 6: Specify the column name if the column order in table is different from the order in CSV file. specify @dummy if to skip data in CSV file.

Leave a Reply

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