How to import .csv files in the database from phpmyadmin

April 8, 2020 / MySQL

To successfully import .csv files into database from phpMyAdmin you need to remember the following – 

Save your Excel file as a CSV file. Please do not save it as a workbook or any other format, check it with Notepad or a similar text reader.

You can see that each column is separated by a comma (,). This is required when we import files with phpMyAdmin. Please remove column headings, blank areas, and ensure that each row and column has some form of entry. The data in the table should be represented equally in the CSV file. If your table has ‘n’ columns you must also have ‘n’ columns in the CSV file.

To import .CSV file into database, follow these steps – 

1.  Firstly, upload .csv file to the public_html directory. 

2. Now, Open phpMyAdmin and select the database where you want to import .csv file. 

3.  Click on the SQL tab.

3. Type following SQL query.

load data local infile ‘Full path for .CSV file’ into table city

fields terminated by ‘,’

enclosed by ‘”‘

lines terminated by ‘\n’

Replace actual full path with “Full path for .CSV file” (/home/username/public_html/filename.csv)

4. Click on Go.

With the help of above steps you can import .csv file into your database using phpMyAdmin. 

Dominos Search