1.打開命令窗口cmd,輸入命令:net stop mysql,停止MySQL服務
2.開啟跳過密碼驗證登錄的MySQL服務
mysqld --console --skip-grant-tables --shared-memory
3.再打開一個新的cmd,無密碼登錄MySQL,輸入登錄命令:mysql -u root -p
密碼置為空,命令如下:
use mysql
update user set authentication_string='' where user='root';
4.關閉以-console --skip-grant-tables --shared-memory 啟動的MySQL服務
5.打開命令框,輸入:net start mysql 啟動MySQL服務
密碼已經置空,所以無密碼狀態登錄MySQL,輸入登錄命令:mysql -u root -p然后直接回車
alter user ‘root’@‘localhost’ identified by ‘新密碼’;
輸入exit,退出當前登錄,輸入登錄命令:mysql -u root -p
輸入密碼,成功登錄,到此,重置密碼結束