ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
Tip: ERROR 1044 (42000): Access denied for user '' @ 'localhost' to database 'mysql'. Two days ago there have this problem, and the Internet to find a more popular method (see method), get. Today they use this tried, but can not handle the Internet looking for a long time, finally found because the user table of mysql database, there is a user account that is named empty anonymous accounts, leading to login when that although using a root , but the actual login is anonymous, 'can be seen by the error message in the' '@' localhost, then the solution, see method two.
Method One:
1. Close MySQL
# STOP-Service mysqld
2. shield permission
# mysqld_safe --skip-grant-table
screen appears: Starting from Demo .....
3. opened a new input terminal
# -u the root MySQL MySQL
MySQL > UPDATE the User the SET Password = PASSWORD ( 'newpassword') the WHERE the USER = 'root';
MySQL> FLUSH PRIVILEGES; // remember to this sentence, or if you turn off the previous terminal, would give rise to the original error
mysql> \ q
Method Two:
1. Close MySQL
# STOP-Service mysqld
2. shield permission
# mysqld_safe --skip-grant-table
screen appears: Starting from Demo .....
3. opened a new input terminal
# -u the root MySQL MySQL
MySQL > the Delete from the User the WHERE the USER = '';
MySQL> FLUSH PRIVILEGES; // remember to this sentence, or if you turn off the previous terminal, would give rise to the original error
mysql> \ q
Reproduced in: https: //my.oschina.net/u/3371661/blog/1830214