How to migrate MySQL DB from one server to another
by Artur on Apr.09, 2009, under Sysadmin
To migrate DB from one MySQL to another over network or Internet you can use following command:
user@computer:$ mysqldump --opt --user=SRC_USER --password=SRC_PASSWORD SRC_DB_NAME | mysql --user=DEST_USER --password=DEST_PASSWORD --host=DEST_HOSTNAME -C DEST_DB_NAME
If the DB is big you can have problems using that command, you should use this method instead:
user@computer:$ mysqldump --opt --user=SRC_USER --password=SRC_PASSWORD SRC_DB_NAME > dump.sql
Then copy dump.sql via scp or anything else you prefer.
Log in on remote server and import DB:
user@computer:$ mysql --user=DEST_USER --password=DEST_PASSWORD --host=DEST_HOSTNAME -C DEST_DB_NAME < dump.sql