1, the phenomenon:
[Email protected] ~]# mysql-u root-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
2, Reason: The existence of empty users in the database caused by
3, the solution method:
1) Disable MySQL service: # service MySQL Stop
2) Input command: # mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
3) Log in database: # mysql-u root MySQL
4) mysql> use MySQL;
5) mysql> select User,host,password from user; The results are as follows:
+------+-----------------------+----------+
| user | Host | password |
+------+-----------------------+----------+
| Root | % | Mima |
| Root | Localhost.localdomain | Mima |
| Root | 127.0.0.1 | Mima |
| | localhost | |
| | Localhost.localdomain | |
+------+-----------------------+----------+
6) Delete the:mysql> delete from user where user= ' "for the empty user queried above;
7) Exit Database:mysql> quit
8) Start MySQL service: # service MySQL Start
9) Log in again with the command ' Mysql-u root-p '. Ok.
Or:
1) Locate the MySQL configuration file. Change the my.cnf. Increase skip-grant-tables in the middle
2) Restart the database service MySQL restart
3) Free password log in with root, then view user table, delete empty user
4) launch the database. Change the my.cnf. Remove Skip-grant-tables
5) Restart the database
MySQL Login error Error 1045 (28000)