如何解決 MySQL報錯:ERROR 1045 (28000)


如何解決 MySQL報錯:ERROR 1045 (28000)

一、問題復現

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

二、問題解決

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
// 修改用戶插件模式,這是報錯的根源所在。

mysql> alter user 'root'@'%' identified by '3n6wxxxxxccj';
// 由於 mysql 不斷更新,重設密碼方式一直變化。
// 該方法是通用方法,故說明。

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
// 記住需要刷新特權表,否則不生效。

mysql> 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM