Import large mysql database using Terminal

403 Views

As a developer I am tasked with importing very large databases into PHPMyadmin on my local server. As many of you that had to do the same know, it can be tedious with timeout issues or other PHPMyadmin errors.

A better and much faster method is to use Terminal on Mac or Windows console.

Step 1.
Export the database to a folder on your computer, this must be a .sql file for this method to work.

Step 2.
Open Terminal and change directory to the location of your .sql file.

cd /path/to/.sql

Step 3.
Run the following in Terminal to execute the sql queries.

mysql -u[USERNAME] -p[PASSWORD] [DATABASE_NAME] <[NAME_OF_SQL_FILE]

Replace the brackets and words in caps with your actual details.If you do not need a password, leave blank then when it asks you for password just click Enter.

Depending on your sql file, this could take a few seconds to minutes.

Enjoy! If you find this tutorial useful, please leave a comment or follow us on Twitter @westernstudios

Please Post Your Comments & Reviews

Welcome to Western Studios

We provide professional website and mobile softwares including Joomla, Wordpress and more.