一、在服務中關閉MYSQL
二、以管理員權限打開cmd,切換到mysql安裝的bin路徑,如:C:\Program Files\MySQL\MySQL Server 5.7\bin
三、以不檢查權限的方式啓動:mysqld -nt --skip-grant-tables
四、重新用管理員權限打開一個cmd窗口,用空密碼方式使用root用戶登錄 MySQL:mysql -u root
五、輸入命令更改root賬戶的密碼爲 root:
1、高級版本沒有password字段,爲authentication_string:update mysql.user set authentication_string=password('root') where user='root' ;
2、老版本有password字段:update mysql.user set password=password('root') where User='root';
六、輸入命令:flush privileges;
七、輸入命令:quit ;
再次登錄就可以了(還不行的話重啓計算機登錄)!