Import Large CSV files to MySQL In a Minute

I have written a php script which can help you import a CSV file with 2 million rows to Mysql in 60 seconds.

You can download the php file from my github page here

Few days back when i was working in my office i had to upload a large csv file to a MySQL database .The csv file had 2 million rows . Phpmyadmin , mysqlworkbecnh doesn't support upload of these large CSV files .The phpmyadmin site suggests a script called big dump which is very slow, found many scripts on the web which try to do a series of insert statements but they are very slow.

After some research found that best way to upload large csv files is to use MYSQL LOAD DATA Command which makes task very easy and fast .


INTO TABLE table name



You can learn more about this command here .

To make the process easier i have written a php script which uses the above command to impost a csv file.This is how the Php page looks like.

Instructions :

1. Keep this php file and Your csv file in one folder
2. Create a table in your mysql database to which you want to import
3. Open the php file from your localhost server
4. Enter all the fields
5. click on upload button



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store