Setting default mysql password


I’m trying to automate a mysqldump with cron. I should be able to specify a default mysql password in “~/.my.cnf”, but nothing seems to be happening when I change the contents of that file. Here’s what I have:

user = website
host = mysql.*******.com
database = website
password = “********”

When I manually execute “mysql” from the shell, I’m still being prompted for a password, and “mysql --help” doesn’t show the changes to the defaults that I set in “~/.my.cnf”, so what am I doing wrong?


Google turned up this:
Could the quotes be interfering with the password? And could the lack of a [mysql] section also be a problem? Maybe the bracketed sections really don’t matter.

Out of curiosity, if you’re keeping your password in a plaintext file, why not put the cron dump command in a shell script with the password and have it run that way?



Haha, I feel so stupid. I had an alias set for “mysql”. Problem solved…

About your question… It is insecure to specify the password for mysql directly in the command because it can show up in proc for a brief moment, allowing anybody to steal my mysql login credentials. And besides, ~/.my.cnf is set to chmod 600. If a hacker can get to that file, then I have much bigger problems to worry about. You can read more about that here:


Nice one! Time to learn more about security :stuck_out_tongue:

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here