I have to deal with fairly large database imports from time to time, which can be a bit of a challenge. phpmyadmin fails pretty miserably when dealing with large database dumps or database imports. Either the SQL files are too large, or the import process takes too long. There are lots of ways around this, but after trying most of them I've found what I think is the easiest way to handle large database imports into MySQL on Windows.

All credit due to Greg at dittio.net who posted a tutorial on this. My only contribution is to say that this works on Windows as well. Here's how I did it:

  1. To make things easy, I moved the SQL file I was importing to a root directory – C:\ or similar.
  2. Run mysql. I don't have it in my path, so I had to navigate to the proper directory to find the .exe. I use the excellent XAMPP, so for me that was C:\xampp\mysql\bin\. On the laptop that I use for development I have no password set for the root user (security alert! OMG!), so the command was just 'mysql -u root'. If you had a password set the command would be 'mysql -u root -p'.
  3. This tutorial assumes there's already a database you want to use. If not, look here for a tutorial on how to create one. Otherwise, switch to that database using the command 'USE {databasename}'.
  4. Then just identify the source SQL file using 'SOURCE {pathtofile};' So, for me that was 'SOURCE C:\dbDump.sql'. Don't forget that semi-colon!

That's it. The import of a 3mb SQL file took about a second. Swoosh.