Move MySQL databases from one server to another

All these commands should be executed on the computer you want to restore the databases to.

Dump the databases from the remote host using mysqldump. Fill in the remote host, username and password in the command.

$ mysqldump --add-drop-table --host=ipaddress --user=root --password=your.password --all-databases > sqldump.sql

To restore the databases locally you simply pipe the file to into a MySQL session.

$ mysql --host=localhost --user=root -p < sqldump.sql

If the source is running a earlier version of MySQL than your new host you might have to run mysql_upgrade. This will repair any incompatibilities between versions.

$ mysql_upgrade --force --password=password