MySQL error 1045(28000): Access denied for user ...
Problem
I have a database called hibernate in my MySQL server and I grant privileges to a user using this command
> grant all on hibernate.* to 'testuser'@'%' identified by 'testuser';
Wildchar % means no matter where the user logs in mysql server from, the access should be allowed for further checking/verification.
When I tried to log in as the newly created user from local host, I got this error:
ERROR 1045 (28000): Access denied for user 'testuser'@'localhost' (using password: YES)
Also I tried some suggested solutions:
> FLUSH PRIVILEGES:
> SET PASSWORD FOR 'testuser'@'%'='testuser';
None of them works.
My solution:
Using following two commands: > grant all on hibernate.* to 'testuser'@'%' identified by 'testuser';
> grant all on hibernate.* to 'testuser'@'localhost' identified by 'testuser';
Theoretically, wildchar % should have included all hosts. But it may not cover localhost. Who knows