mysql login error message: ERROR 1045 of 28000 solution

  • 2020-12-26 05:54:30
  • OfStack

This paper analyzes the solution of mysql login error prompt: ERROR 1045 (28000). To share for your reference, the details are as follows:

1. The question is:

root users of the mysql database on the company's linux system have set passwords, but often log in with the command 'mysql-ES11en ES12en-ES13en' and sometimes log in again. The login error message is:


[root@localhost ~]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

2. Reason: there is an empty user in the database

3. Solutions:

1. Stop the mysql service:


# service mysql stop

2. Input 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;

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 empty users found above:


mysql> delete from user where user='';

7. Exit the database:


mysql> quit

8. Start mysql Service:


# service mysql start

9. Re-use the command:


mysql -u root -p

Login, OK!

For more information about MySQL, please refer to MySQL Transaction Operation Skills Summary, MySQL Stored Procedure Skills Collection, MySQL Database Locking Skills Summary and MySQL Common Functions Summary.

I hope this article has been helpful to you with the MySQL database.


Related articles: