4

Tip #766   Migrate MySQL Database to a new Server

Tip 669 gave a command to copy a table between remote MySQL databases, but how about if you want to copy the whole DB to a new host?

The following command will copy the database 'old_db' from the local host to 'new_db' on the specified remote host.

mysqldump --add-drop-table --extended-insert --force --log-error=err.log -u[user] \
-p[pass] old_db | ssh -C user@host "mysql -u[user] -p[pass] new_db"