Warning: strpos() [function.strpos]: needle is not a string or an integer in /home/beardedd/public_html/home/index.php on line 61
hOme.beardedDonkey - mysqldump gives Error 1045 access denied when using .my.cnf for automated backups using sh script
mysqldump gives Error 1045 access denied when using .my.cnf for automated backups using sh script 
I had to change my passwords recently and I found that after I did this for the credentials used to access my mysql databases that my automated backup scripts became broken. I finally found a fix for this.

It turned out that if you use special characters in your passwords like !@#$%^&*() this will confuse mysqldump when it's reading your login credentials from a my.cnf file.

The my.cnf file is used mostly when you want to create an automated method of backing up your mysql database contents. Since the process is automated and it needs a password, it's a security risk to just use the -p switch with mysqldump in your shell script because the password will be exposed in plain text in the process list of the machine while the mysqldump process runs.

The my.cnf file holds the login credentials on disk, but are set to be only readable by your user, so other users can see what's in the file. The mysqldump process can read the file to get the credentials, keeping them safe.

I found a forum posts here: https://www.virtualmin.com/node/21032 by chitoz that had a small mention about the character # being used in his password and it creates problems.

The fix for this was to edit the my.cnf file and enclose the password string in single quotes:

[client]
username = user
password = 'specialChars@$#&%'

[ view entry ] ( 132 views )   |  [ 0 trackbacks ]   |  permalink  |   ( 2.9 / 210 )

<Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>