The error information is as follows:
[root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Cause of the problem.
There are empty users in the database
Solution:
1 Disable mysql service: # service mysql stop
2 Enter the command: # mysqld_safe –user=mysql –skip-grant-tables –skip-networking &
3 Login to the database: # mysql -u root mysql
4 mysql> use mysql;
5 mysql> select user,host,password from user;
6 Delete the empty user from the above query: mysql> delete from user where user=”;
7 Quit the database: mysql> quit
8 Start mysql service: # service mysql start
9 Log back in: # service mysql start # mysql -u root -p