15
May

MySQL Dump to another server

Recently – while doing some work for COR.org – I was asked how to dump a database from one server to another… (mysql)

The first thought was to run mysqldump dump on the destination machine, and to access the database over the network. That however, doesn’t compress or encrypt the data. Plus I would have had to create a mysql user with permission to access the database remotely.

The solution used instead worked out well: mysqldump directly to the remote host with this command:

mysqldump <DATABASE_NAME> [mysqldump options] | gzip -c | ssh user@remotehost "cat > /path/to/some-file.sql.gz"

In short – this method pipes the mysqldump command through gzip, then to through and SSH connection. SSH on the remote side runs the ‘cat’ command to read the stdin, then redirects that to the actual file where you want it saved.

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment