30 December 2008
MySQL : import a dump
This is an easy thing but I never took the time to figure it out because I use phpMyAdmin so much. Exporting a database is easy with phpMyAdmin, but importing if it is large can be hard because a lot of times your connection will time out or PHP is restricting how big you can upload or whatever. If you can SSH, this is easier:
mysql -u USER -p DBNAME < dump.sql
If you are on Media Temple’s DV server, like us, you can do this:
my DBNAME < dump.sql
So much easier!
Comments
How to export from the command line:
mysqldump --add-drop-table -u Username -p dbname > dbname.sqlFrom:
http://kb.mediatemple.net/questions/129/How+can+I+Backup+and+Restore+a+MySQL+database%3F
Path to MySQL with a MAMP installation:
/Applications/MAMP/Library/bin/mysql
You can list table names after dbname to only get some tables. Such as:
mysqldump --add-drop-table -u Username -p dbname tblname1 tblname2 > dbname.sql