Monday, December 24, 2012

MySQL - ERROR 1045 (28000): Access denied for user

When you get a weird permissions denied error while connecting to MySQL considering that,

1. You have properly granted privileges to the user.
2. That the user logs-in from a host that's permitted by the the database server.
3. That you have entered the correct username + password combination.
4. That you are accessing a database that the user have been granted permission

Then, you are most likely a victim of a setup that has an anonymous user. How to verify and fix.

1. Check if anonymous users exist.

> use mysql;
mysql> SELECT user,host from user where user='';

2. If you have matches, delete them.

> use mysql;
mysql> DELETE from user where User = "";

If it doesn't work, then it must be something else which I'd be curious with such findings so let me know.

Note: This works on both MySQL and MariaDB

  • Related Links Widget for Blogspot

No comments: