MySQL scripts

In order to do a MySQL dump on a remote machine with ssh, one can do it with the following command:

ssh name@URL 'mysqldump -u root dbname -ppasswd > dbname.sql'

This results in the following Warning:

Warning: Using a password on the command line interface can be insecure

In order to avoid it, add the file

~/.my.cnf

in the remote machine home directory, with the lines

[client]
password="passwd"

and change its permissions with

chmod 600 ~/.my.cnf

and use the following command instead:

ssh name@URL 'mysqldump -u root dbname > dbname.sql'

Leave a Reply

Your email address will not be published. Required fields are marked *