MySQL backup from command line without a password prompt

Create a file called ~/.my.cnf

Add the following to this file

[mysqldump]
user=myuser
password=mypass

Change permission of this file to 600

Now mysqldump can be run without a password prompt

mysqldump --all-databases > all_databases.sql
Advertisements