1. 程式人生 > 其它 >win10系統下mysql密碼忘了這麼解決?

win10系統下mysql密碼忘了這麼解決?

技術標籤:mysql常見解決方法mysql

win10系統下mysql密碼忘了這麼解決?

開啟命令視窗cmd,輸入命令:net stop mysql,停止MySQL服務


二、使用步驟

開啟跳過密碼驗證登入的MySQL服務

程式碼如下(示例):

1.mysqld --console --skip-grant-tables --shared-memory 

2.讀入資料

再開啟一個新的cmd,無密碼登入MySQL,輸入登入命令:mysql -u root -p
將密碼設定為空,命令如下:
程式碼如下:

1. use mysql
2. update user set authentication_string=
'' where user='root';

關閉以-console --skip-grant-tables --shared-memory 啟動的MySQL服務
開啟命令框,輸入:net start mysql 啟動MySQL服務
密碼已經置空,所以無密碼狀態登入MySQL,輸入登入命令:mysql -u root -p然後直接回車
輸入以下程式碼設定新密碼alter user ‘root’@‘localhost’ identified by ‘新密碼’;

1. alter user ‘root’@‘localhost’ identified by ‘新密碼’;