Backup or Export, Compress and upload mysql database to remote host

This is a handy command that i use to backup or export, compress and upload a mysql database to my remote host, very handy when you wanna upload your development database to the remote host after some changes.

/usr/mysql/bin/mysqldump --opt -uUsername -pPassword Databasename  | gzip -c | ssh -q user@remote-host.com 'cat > ~/Databasename.sql.gz'

Replace the following :

  • /usr/mysql/bin/mysqldump : The path for mysqldump on your localmachine
  • Username : Username for local mysql database.
  • Password : Password for local mysql database.
  • Databasename : Name of the database to export.
  • user@remote-host.com : the user and the IP or the address of the remote host.

the above command will upload the compressed database to your home directory on the remote host, to change the directoy, replace ~/ with the path you want.

4
Leave a Reply

avatar
3 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
4 Comment authors
aibrahimDmitry Perfectophparchsikas Recent comment authors
  Subscribe  
Notify of
sikas
Guest
sikas

well, that is for the linux, what about the windows?

Dmitry Perfecto
Guest

Sorry, but where do you put ssh pass?