win10下,MySQL5.5.61重置密碼
阿新 • • 發佈:2019-01-04
前段時間要登入MySQL時,發現忘記了密碼,多次上網查資料後並一一驗證,才找到適合我使用的方法。
作業系統:win10
MySQL版本:5.5.61
1. 使用管理員身份執行notepad++,開啟MySQL安裝目錄C:\Program Files\MySQL\MySQL Server 5.5下的配置檔案my.ini。 2. 在my.ini檔案“mysqld”關鍵字下新增“skip-grant-tables”(該命令用於跳過密碼問題) 3. 使用管理員身份執行cmd,重啟MySQL服務 在任意目錄下執行以下命令:(安裝MySQL時配置了全域性變數,故可在任意目錄下執行) net stop mysql net start mysql
mysql> use mysql;
mysql> update mysql.user set password='[email protected]' where user='root'; 注:據說5.7版本的密碼欄位是authentication_string,之前的是password。
密碼重置後,還需要賦予root許可權,否則重置密碼後的root無法連線MySQL服務。 mysql> flush privileges; 先重新整理許可權
mysql> grant all privileges on *.* to [email protected]'localhost' identified by "[email protected]"; 賦予所有許可權給root使用者
mysql> quit;
5. 密碼重置後,把my.ini檔案剛才新增的“skip-grant-tables”刪除,儲存檔案。(刪掉免密登入) 6. 重啟MySQL,用新密碼登入MySQL使用者root。
操作就到此為止了。
在這裡要感謝幾位博主:
1. 大資料和AI躺過的坑:https://www.cnblogs.com/zlslch/p/5937784.html
2. 賤書生:https://www.cnblogs.com/rnckty/p/5577818.html