How To Investigate/Restore MySQL Permissions? MySQL ERROR 1045 (28000): Access denied for user

Posted by Recc on Super User See other posts from Super User or by Recc
Published on 2012-12-07T11:45:50Z Indexed on 2012/12/07 17:13 UTC
Read the original article Hit count: 259

Filed under:
|
|

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Debian.

mysqld is listening on 3306 supposedly

Telnet to 3306 works

Also tried binding it specifically yo localhost and then 127.0.0.1 which made no difference

However:

# netstat -ln | grep mysql
unix  2      [ ACC ]     STREAM     LISTENING     78993    /var/run/mysqld/mysqld.sock

# mysql -P3306 -ptest
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Things I've tried:

dpkg-reconfigure mysql-server-5.1  Doesn't help

http://www.debian-administration.org/articles/442 Doesn't help

This command (source):

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;

Doesn't help, in fact:

Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

So might the user be deleted? Extremely unlikely as all this started after packages update a colleague did and some separate services started screwing around but my colleague said he removed the offenders.

Theres more: while # mysqld_safe --skip-grant-tables is running one can access the data tables, only with the valid passwords! So there's users and some authentication takes place hence the 0 rows affected above.

Can the privileges tables be damaged somehow and how can I recreate/restore them when my only way of getting a mysql console is to skip them?

Can I spare my reinstall of MySQL? Either way I did get a dump of the DBs now that I could get in with the above mode.

© Super User or respective owner

Related posts about linux

Related posts about debian