importing a CSV into phpmyadmin importing a CSV into phpmyadmin database database

importing a CSV into phpmyadmin


In phpMyAdmin, click the table, and then click the Import tab at the top of the page.

Browse and open the csv file. Leave the charset as-is. Uncheck partial import unless you have a HUGE dataset (or slow server). The format should already have selected “CSV” after selecting your file, if not then select it (not using LOAD DATA). If you want to clear the whole table before importing, check “Replace table data with file”. Optionally check “Ignore duplicate rows” if you think you have duplicates in the CSV file. Now the important part, set the next four fields to these values:

Fields terminated by: ,Fields enclosed by: “Fields escaped by: \Lines terminated by: auto

Currently these match the defaults except for “Fields terminated by”, which defaults to a semicolon.

Now click the Go button, and it should run successfully.


In phpMyAdmin v.4.6.5.2 there's a checkbox option "The first line of the file contains the table column names...." :

enter image description here


Using the LOAD DATA INFILE SQL statement you can import the CSV file, but you can't update data. However, there is a trick you can use.

  • Create another temporary table to use for the import
  • Load onto this table from the CSC

    LOAD DATA LOCAL INFILE '/file.csv'INTO TABLE temp_tableFIELDS TERMINATED BY ','LINES TERMINATED BY '\n'(field1, field2, field3); 
  • UPDATE the real table joining the table

    UPDATE maintableINNER JOIN temp_table A USING (field1)SET maintable.field1 = temp_table.field1