Archive for October 31st, 2010

Transfering MySQL databases between Servers via SSH

Usually, when transfering a MySQL database from one server to another, people pipe the output of mysqldump into a file, archive it if it is large, upload it to the remote host, unarchive it, and then pipe it into the MySQL instance from that shell.

There is a much easier way, although it doesn’t archive the data first.. but usually unless you’re dealing with larger tables, the ease of using this method makes slower transfers very acceptable.

mysqldump -u user -ppassword databasename | ssh "mysql -u user -ppassword databasename"