Running mysqldump via ssh (direct host to host copy)

In order to run a mysqldump from one host to another over SSH you can run:

mysqldump dbname | ssh root@remotehost.com "mysql -D dbname"

This will pipe the output of mysqldump directly to the ssh connection which is running MySQL at the other end and receiving the mysqldump from standard input.

2 Responses to Running mysqldump via ssh (direct host to host copy)

  1. Vaselinessa July 3, 2011 at 6:05 pm #

    What if I’m using Putty to ssh from windows to a linux server? i.e. my command line command isn’t:

    >>> ssh

    rather:

    >>>putty -load “[my saved session]”

    I ask because when I run the foregoing, it won’t let me tack on a command to run once the connection is established.

  2. Vaselinessa July 3, 2011 at 7:42 pm #

    Looks like someone on stackoverflow.com answered it for me: http://stackoverflow.com/questions/6564882/automate-mysqldump-to-local-computer-windows

Leave a Reply