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

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 user@remote.box.com mysql db-name
OR
$ mysqldump -u username -p’password’ db-name | ssh user@remote.box.com mysql -u username -p’password db-name

You can just copy table called foo to remote database (and remote mysql server remote.box.com) called bar using same syntax:
$ mysqldump db-name foo | ssh user@remote.box.com mysql bar
OR
$ mysqldump -u user -p’password’ db-name foo | ssh user@remote.box.com mysql -u user -p’password’ db-name foo