Windows下Mysql5.7忘記root密碼的解決方法

1、打開第一個cmd窗口執行 net stop mysql57

2、在第一個cmd窗口執行 mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --skip-grant-tables   ---注意路徑(以你的實際情況爲準)

3、打開第二個cmd窗口執行 mysql -uroot -p        提示輸入密碼,直接回車(不用輸入密碼)

4、選擇數據庫:use mysql;

5、更新root的密碼:update user set authentication_string=password('新密碼') where user='root' and Host='localhost';

6、刷新權限:flush privileges;

7、退出:quit

8、重新登錄:mysql -uroot -p       提示輸入密碼,這時輸入密碼才能登錄。完成!!!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章