MYSQL ERROR 1045 of 28000: Access denied for of using password: resolution of YES problem

  • 2020-05-09 19:23:50
  • OfStack

Method 1: recommend
Error description: ERROR 1045 (28000) may be prompted for login after adding a user to Mysql: Access denied for user error.

Reason analysis: records with empty user may appear in the mysql.user table, such as:

mysql > select host,user from user;
+------------------+------+
| host | user |
+------------------+------+
| % | test |
| localhost | |
| localhost | root |
+------------------+------+
3 rows in set (0.00 sec)

Solution: delete these empty users or update them to other user names

Delete user.user median of NULL, or update NULL to test

1)delete from user where user is NULL
2)update user set user='test' where user is NULL

Unexpected situation: if the above method does not work and there is still an empty user, the graphical user client can be deleted.

The second method: linux
Prologue: solving LINUX problem is a kind of fun, of course, can meet the problem is a god-given opportunity to enjoy happiness.
This time, Mandriva2008spring is used.
Since we need to install MySql for a project, we need to install MySql. In the past, the installation of MySql was very smooth, especially the rmp package provided by MySql, which can be solved by double-clicking. However, we do not know when MYSQL ERROR 1045 (28000): Access denied for user (using password: YES), this access denial problem becomes very widespread.
Baidu 1, there is no ready-made solution, only to find out where the problem is.
Solutions:
Step 1, first use the skip authorized table access command: mysqld_safe --user=mysql -- skip-grant-tables -- skip-networking & (of course, before that, stop the mysql service).
Step 2, mysql-uroot mysql log on to mysql.
Step 3, access the user table in the mysql database. On my machine, mysql > select * from user; And what you get is this
Empty set (0.00 sec). This indicates that my mysql does not have any accessible users. Once you know what the problem is, it's easy to solve it.
Step 4, mysql > INSERT INTO user(host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'username', 'PASSWORD ',' Y', 'Y',' Y','Y');
Query OK, 1 row affected, 3 warnings (0.00 sec)
Return success, no problem. Hey hey ~~~ so simple.
Step 5: test, restart mysql service, log in normally, successful!!

Note: the mysql database in the mysql system stores system data. The user table here stores user information and access rights. For example, if you want to create a new database, mydb, which is managed by the me user, the db table in the mysql database will store relevant information. Talk too much nonsense.

Here is windows's solution:
But if we use the virtual host management system opened users, and the number of users when more, it seems that is not a good way.

I used to re-install mysql, and then enter the virtual host, one by one to delete, re-open the database, before the operation 1 must back up the original data directory, and finally overwrite the space database can be.

Related articles: