1、运行cmd,目录定位到MySql的安装目录“C:Program FilesMySQLMySQL Server 8.0in”
2、运行mysql
mysql -u root -p
3、运行如下的两个命令
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
4、运行如下指令刷新密码,并更新密码
FLUSH PRIVILEGES; alter user 'root'@'localhost' identified by '新密码';
5、再次连接就可以了