Home DATABASE How do import from CSV file to Mysql Database using PHPMyAdmin

How do import from CSV file to Mysql Database using PHPMyAdmin

Writing a sql code is not required. Just use the phpMyAdmin interface for uploading the csv file.

  1. I assume that you have created
    • a mysql database and within it a table with appropriate fields
    • a csv file with entries arranged in the same order as the fields in the mysql database table (eg Suppose you have a table with fields name, age, city. Your csv file might look like –
    Kumar,11,Bangalore assuming you use ‘,’ as field separator and ‘\n’ as row separator
  2. Go to phpMyAdmin (It should be located in your host account control panel under database section)
  3. Click on the mysql database instance you are interested in.
  4. Click on the table to which you want to import the data. (Remember this step, just clicking on the database is not good enough.)
  5. Click on the ‘import’ tab.
  6. This will open an interface as shown below –
    • Click ‘Browse’ button to select the csv file on your system which you want to upload
    • Choose ‘CSV using LOAD DATA’
    • Fields terminated by: ,
    • Fields enclosed by: [delete default value, leave blank]
    • Fields escaped by: [delete default value, leave blank]
    • Lines terminated by: [leave default value]
    • Column names: name,age,city

Click the ‘GO’ button and you are done. phpMyAdmin will show you exactly what sql query was executed to upload the csv file into your mysql database table. You can now browse your database to check proper insertion of the csv file.

You may also like

Leave a Comment