Setting default mysql password

Setting default mysql password

Posted by: geofflee
Posted on: 2008-05-02 06:27:00

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:

[client]
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?

Re: Setting default mysql password

Posted by: sdayman
Posted on: 2008-05-02 07:20:00

Google turned up this:
http://www.modwest.com/help/kb6-242.html
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?

-Scott

Re: Setting default mysql password

Posted by: geofflee
Posted on: 2008-05-02 07:37:00

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: http://dev.mysql.com/doc/refman/4.1/en/password-security.html

Re: Setting default mysql password

Posted by: patricktan
Posted on: 2008-05-02 09:00:00

In reply to:

http://dev.mysql.com/doc/refman/4.1/en/password-security.html


Nice one! Time to learn more about security tongue

Tags: mysqldumpcronshell