How to copy a database with mysqldump from remote server to another via ssh

December 23, 2010    mysqldump remote mysqldump

How do I copy a MySQL database from one computer/server to another?

Short answer is you can copy database from one computer/server to another using ssh.

SSH is the only secure method of transferring so i will not even talk about using mysql.

Use ssh if you don't have direct access to remote mysql server (secure method):

$ mysqldump db-name | ssh mysql db-name
$ mysqldump -u username -p'password' db-name | ssh mysql -u username -p'password db-name

You can just copy table called foo to remote database (and remote mysql server called bar using same syntax:
$ mysqldump db-name foo | ssh mysql bar
$ mysqldump -u user -p'password' db-name foo | ssh mysql -u user -p'password' db-name foo

blog comments powered by Disqus