MySQL 忘記密碼解決方案

1、管理員身份打開命令行

net stop mysql

2、跳過用戶驗證

  mysqld --skip-grant-tables 

3、管理員身份打開新窗口,輸入

mysql

image.png

4、進入mysql數據庫

use mysql;

5、重新設置密碼

update user set password=password('123456') where user='root' and host='localhost';

如果出現以下錯誤,則將命令改爲

update user set authentication_string=password('123456') where user='root' and host='localhost';

修改後exit退出
image.png

6、啓動mysql服務並登錄

net start mysql
mysql -uroot -p123456

image.png

修改成功

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