How to import large MySQL databases

Lets say that you have a huge blog which comes with a huge database and you are fed up with your current host A and want to move your precious blog to host B. The problem is that most hosts will set limitation on their virtual accounts and when you try to import the huge databases using phpMyAdmin it will time out.

First of all when you EXPORT a large database make sure that the Extended inserts under the Data panel is un-checked (see the picture below).

Then go ahead , export your database and save the .sql file to your hard drive. Also make sure that these fields under Structure are checked:
Add DROP TABLE / VIEW / PROCEDURE / FUNCTION
Add IF NOT EXISTS
Add AUTO_INCREMENT value
Enclose table and field names with backquotes

Good, now you have a nice 200MB .sql file on your hard drive ready to import to your newly created database. All you need is a little tool called BigDump.

Download the BigDump.zip file from the BigDump web site, unzip it, open it with your favorite text editor and change the database hostname, name, username, and password. FTP to the domain you moved to your new host, create a new directory (say /bd/) and upload the bigdump.php and the database .sql file to that directory.

Now launch your browser and navigate to the bigdump.php file:
http://www.MySite.com/bd/bigdump.php

Click the Start Import link and wait for the import to finish. If you get any errors during the process please make sure to read the BigDump FAQ.

That’s it!