ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
So, I was happily using this script to backup my mysql databases:
http://sourceforge.net/projects/automysqlbackup/ It was working great until yesterday when I played around with /etc/hosts, /etc/sysconfig/network and /etc/resolv.conf file to fix up my hostname and stuff and now this script is not working. When i run the script, i get the following error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Please note that I can login just fine using my root account from the shell: mysql -u root -p Here is the stanza of the backup script that is relevant: Code:
# Username to access the MySQL server e.g. dbuser ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) INSTEAD of 'root'@'127.0.0.1' I changed the following files to these: Code:
[root@proliant ~]# cat /etc/hosts |
If I were you, I would consider simply:
* Add a new user "root@localhost" to mysql * Make sure this "root@localhost" has the right password, and all the necessary grants * You should be done Alternatively, you could give your existing "root" user a wildcard hostname (if it doesn't already). 'Hope that helps .. PSM PS: Google for "ERROR 1045" - you'll find a zillion hits .. and probably a few good suggestions (if the above doesn't work for you). |
Just because I ran into this issue with another program recently... try making your localhost line in hosts look like this: '127.0.0.1 localhost localhost.localdomain serv1.domain.tld serv1' You can also try adding --verbose to your mysql command line to get more information. If you select out your user from mysql what does that look like?
You could also try setting DBHOST to 127.0.0.1 |
Thanks paulsm4 for your prompt response. However, I already have a user root@localhost in my mysql.user table. And I know the password I have in my script is correct, cuz i can login with that password using the following:
mysql -u root -h localhost -p |
Quote:
I would show you the output from the cmd below user mysql; select * from user where user='root'; but I get too many column from the above cmd. How to show only 1st 3 columns or so? |
Does this work?
Code:
/etc/hosts |
Quote:
(dont want password encrypted or otherwise ;) ) |
Also, look here:
Quote:
|
Quote:
|
Quote:
Code:
sudo grep -a -o -e '.*root' /var/lib/mysql/mysql/user.MYD Code:
ls -l /var/lib/mysql Code:
cat /etc/hosts Code:
grep bind-address /etc/mysql/my.cnf Also, from the last cmd, i do not have the bind-address directive. But I didn't have that before either and everything was working fine. Thanks for your efforts. Really appreciate it! |
Quote:
If not issue `hostname serv1` to set it till the next boot. If you changed the hostname in /etc/sysconfig/network and did not either reboot or issue the hostname command with the new hostname then it is probably inconsistent. perhaps restart mysql after setting the hostname too. |
Maybe login to the DB manually and run
SHOW GRANTS http://dev.mysql.com/doc/refman/5.0/en/show-grants.html to see what the DB thinks/expects. |
Hi, bobby953 -
I understand that things were probably working fine before you changed a couple of networking files. But your mysql "identity" is a combination of mysql user, Linux user/group and ... yes, Linux hostname. Further complicating things, there are subtle differences between IPV4 and IPV6 that might also be an issue here. So let's start from the top, and pull together all the suggestions folks made, combined with what you've already tried. Shall we? I'll give you examples from my Ubuntu 9.10 server, which is probably reasonably close to whatever you've got. Quote:
One final bit of food for thought: Q: What *is* that funny "bind-address", anyway? A: It allows remote access, or restricts you to local access only |
paulsm4, awesome post... will follow your guideline exactly tomorrow.. it's 4 am and i'm so sleepy... lol... really appreciate your efforts!
|
Code:
uname -a Code:
mysql --version Code:
mysql> select host,user from user; Code:
mysql> show grants; Code:
sudo grep -a -o -e '.*root' /var/lib/mysql/mysql/user.MYD Code:
grep bind-address /etc/my.cnf Code:
ping localhost Code:
ping 127.0.0.1 Code:
hostname Then i changed it to serv1.domain.com and the mysql backup script broke. Thanks again for all ur help :) |
All times are GMT -5. The time now is 08:48 PM. |