How to solve MySQL error: ERROR 1045 (28000)

created at 10-18-2021 views: 1

problem description

┌──(rabbitASUS)-[/mnt/c/Users/rabbit]
└─$ mysql -uroot -p3xxxxxxxS9uccj -h192.168.xxx.xxx
ERROR 1045 (28000): Access denied for user 'root'@'ASUS.lan' (using password: YES)

solution

mysql> select user, plugin from mysql.user;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| root | auth_socket |
| debian-sys-maint | caching_sha2_password |
| mysql.infoschema | caching_sha2_password |
| mysql.session | caching_sha2_password |
| mysql.sys | caching_sha2_password |
+------------------+-----------------------+
5 rows in set (0.00 sec)

mysql> update mysql.user set plugin='mysql_native_password' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
// Modify the user plug-in mode, this is the source of the error.

mysql> alter user'root'@'%' identified by '3n6wxxxxxccj';
// Since mysql is constantly updated, the method of resetting the password has been changing.
// This method is a general method, so it is explained.

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
// Remember to refresh the privilege table, otherwise it will not take effect.

mysql>
Please log in to leave a comment.