Importing MySQL DBs via command line

Okay, so wow. I had a pretty obese database I wanted to move from one server to this one (my Slicehost acct) and PHPMyAdmin just couldn’t handle an 11MB table or something; I was even breaking it down so that it only had to import one table at a time, to no avail.

So naturally this seemed like something that could be done from the command line with ease. Heh.

First, I uploaded the exported version of my gzipped database to the root of my home directory.

gunzip mydb.sql.gz #unzip the database
mysql -u username -p newdbname < ~/mydb.sql

That's it. Seriously.
One thing to note is that I already had '

newdbname

' created. But otherwise it was extremely straightforward (after I spent at least an hour figuring it out :P).

Leave a Reply