mysql8忘記密碼的解決方法
1.管理員身份打開cmd,進入dos
2.停止mysql服務
命令:net stop mysql

3.無密碼啟動
命令:mysqld --console --skip-grant-tables --shared-memory

4.另啟一個dos窗口,無密碼登錄
命令:mysql -u root
5.清空密碼
命令:update mysql.user set authentication_string='' where user='root' and host='localhost';
注意:authentication_string采用的是plugin加密方式,故設置為空,不要設置為其他值

6.啟動服務
關閉打開的兩個dos窗口,然后以管理員身份重新打開一個dos窗口,啟動服務
命令:net start mysql

7.無密碼登錄
命令:mysql -u root

8.重新設置密碼
修改后,就可以用新密碼登錄了。
命令:alter user root@localhost identified by 'root';

9.退出mysql服務
命令:quit;

10.用修改后的用戶名密碼登陸
命令:mysql -u root -proot

