How to import CSV file to MySQL using phpMyAdmin

Here’s one way to get your Excel file into MySQL via phpMyAdmin:
(NOTE: make sure your table on MySQL has the same number of columns as the excel file):

1. Export your .xls file to .csv and remove the first line (column names)
2. Launch phpMyAdmin -> select table

Import ->
Location of text file ->
CSV using LOAD DATA ->
Fields terminated by [,] ->
Fields enclosed by [ ] ->
Fields escaped by [ ] ->
Lines terminated by [r] -> Go

9 comments on “How to import CSV file to MySQL using phpMyAdmin”

  1. Thank you! This was a BIG help.. I have a small problem now, what if some of my fields already have commas within the entries – how would i go about fixing that?

  2. I’m amazed this helped everyone so well. Eveyone shows the command to load the file but no one shows an exaple of what the fiile should look like. Does anyone care to show an example of what the file should look like? (the file that you are importing)

  3. You are probably the only man who knows how to import csv data. Thanks a ton. Can u pl. tell me the reason for using /r in the field “Lines terminated by”. Thanks a ton again.

  4. Seriously, you don't know how many people have been challenged with problem, and you made it look so simple. It's a gift i guess. Thanks, you're the Best…

Leave a Reply

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