Problem phenomenon:
Error message:
ERROR 1044 (42000): Access denied for user "@ ' localhost ' to database ' MySQL ' or
ERROR 1045 (28000): Access denied for user ' roort ' @ ' localhost ' (using Password:yes)
Cause of failure:
The user table in the MySQL database has an account with an empty username, which is an anonymous user. Causes the log in the time although uses the root, but actually is the anonymous login, through the error prompt ' @ ' localhost ', can see.
Workaround:
1. Stop mysqld service
[[Email protected] ~]# service mysqld stop
2 , in the configuration file /etc/my.cnf Add Skip-grant-tables One line, skip password verification
[Email protected] ~]# VIM/ETC/MY.CNF
[Mysqld]
Datadir=/data/mysql
User=mysql
Log-bin=mysql-bin
Basedir=/usr/local/mysql
skip-grant-tables// Add Skip-grant-tables
3, start the Mysqld service, in the new open terminal input
[[email protected] ~]# MySQL
mysql> use MySQL;
Mysql> Select User from user;
+------+
| user |
+------+
| Root |
| Root |
| Root |
| |
| |
| Root |
6 rows in Set (0.00 sec)
you can see that there are 2 anonymous accounts with a blank user name.
mysql> Delete from user where user= ';
Query OK, 2 rows Affected (0.00 sec)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
4, in the configuration file /etc/my.cnf Delete skip-grant-tables
ERROR 1045 (28000): Access denied for user ' roort '