
MySQL ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: YES)
August 25, 2008The other day I got this error on one of our servers. Fantastico module in cpanel was showing the error: Unable to connect to mysql database. While mysql service was running fine, the root user was unable to login to mysql database. I initially tried to reset the mysql root password like http://rhcelinuxguide.wordpress.com/2008/08/08/reset-mysql-root-password/ but that did not help. The real issue was permission on the folder /var/lib/mysql/mysql . It is supposed to be 711 , while it was 751. That fixed it.
==================================================================
root@server1 [~]# mysql
ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: YES)
root@server1 [~]#
root@server1 [/var/lib/mysql/mysql]# ls -lhd /var/lib/mysql
drwxr-x–x 179 mysql mysql 12K Aug 25 01:44 /var/lib/mysql/
root@server1 [/var/lib/mysql/mysql]# chmod 711 /var/lib/mysql/mysql
root@server1 [/var/lib/mysql/mysql]# ls -lhd /var/lib/mysql/mysql
drwx–x–x 2 mysql mysql 4.0K Aug 25 01:32 /var/lib/mysql/mysql/
root@server1 [/var/lib/mysql/mysql]# service mysql restart
Shutting down MySQL..
Starting MySQL [ OK ]
root@server1 [/var/lib/mysql/mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51a-community MySQL Community Edition (GPL)Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> quit
Bye
root@server1 [/var/lib/mysql/mysql]#
root@server1 [~]# safe_mysqld –skip-grant-tables &
root@server1 [~]# mysql
root@server1 [~]# USE mysql
mysql> UPDATE user SET password=password(“new root passwd”) WHERE user=”root”;
mysql> flush privileges;
mysql> exit
root@server1 [~]# killall mysqld mysql
root@server1 [~]# /etc/init.d/mysqld start
You can check the root mysql password in /root/.my.cnf ( assuming you have set it up)
Sample /root/.my.cnf
#######################
root@server1 [~]# cat /root/.my.cnf
[client]
user=”root”
pass=”V1<)4K5.8″
root@server1 [~]#
When i typed the following command :
service mysql restart
I got the errr msg service mysql not found
# service mysqld restart
when i tried typing service mysql restart, it produces error : unrecognized service.
okay, i already tried the mysqld. and it works, but still producing the ” Access denied for user: ‘root@localhost’(Using password:No)
BIG THANKS for that chmod
was desperate already
Hello,
In my case it’s not so much working…
When I issue:
& service mysql restart
I get:
mysql start/running, process 29880
But when I require:
& mysql
I get the same previouse:
ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)
More ideas?
I’m under Ubuntu lucid…
Regards,
Sam
i’m using ubuntu lucid too… & have same error… please…
Another reason for the error could be permission issue, Click here for full details
i have this error…
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.1.48-community MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show grants;
+——————————————————————————-
——+
| Grants for root@localhost
|
+——————————————————————————-
——+
| GRANT UPDATE ON *.* TO ‘root’@'localhost’ IDENTIFIED BY PASSWORD ’446a12100c85
6ce9′ |
+——————————————————————————-
——+
1 row in set (0.00 sec)
mysql> GRANT SELECT ON *.* TO ‘root’@'localhost’ IDENTIFIED BY PASSWORD ’1234′;
ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: Y
ES)
mysql>
…please help me……….
why are you using different password for the same user one for granting update and the other for granting select? try using same passwd and check