MySQL_ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)_重置root密碼

 

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

(using password: NO) 表示嘗試連接時沒有提供密碼。
(using password: YES) 表示嘗試連接時提供了密碼。



我這邊起初密碼是rootroot

如果出現的是這種錯誤,絕大部分偏向是更改過密碼但忘記了用上一次記憶中的密碼。
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
表示我們嘗試以root用戶連接MySQL資料庫時提供的密碼不正確。


重置root密碼
Step1.開啟Windows「服務」管理工具(可以在開始菜單中搜索「services.msc」),找到MySQL服務,並停止它。

指令方式:
taskkill /F /IM mysqld.exe

以下是介面方式:
當你關閉MySQL服務後,3306服務此時就沒有相關服務在使用了。

Step2.在C槽新增一個mysql-init.txt
內容如下
ALTER USER 'root'@'localhost' IDENTIFIED BY '你想更換的新密碼';


Step3.用cmd並以系統管理員來啟動
下以下指令
mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\\mysql-init.txt" --console


Step4.另外去開Command Line Client確認是否可用新密碼登入

確認密碼已更改成新的了

Step5.將剛開起的cmd都關閉後,再重啟MySQL服務即可。

此時你用新的密碼來cmd登也可以成功。





Ref:
How to start MySQL with --skip-grant-tables?

How to restart MySQL with --skip-grant-tables if you can't use the root password?

忘记mysql root用户密码的解决办法(skip-grant-tables)

mysql--慎用--skip-grant-tables命令--忘记用户名密码(Linux環境)

MySQL --skip-grant-tables 選項關閉(Linux環境)

How to Reset MySQL Root Password on Windows [WORKING!!]
https://www.youtube.com/watch?v=V8_fpBE9deA&ab_channel=CSCORNERSunitaRai




留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

Architecture(架構) 和 Framework(框架) 有何不同?_軟體設計前的事前規劃的藍圖概念

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題