1.首先停止mysql服务 net stop mysql
2.进入到mysql安装目录执行 mysqld --skip-grant-tables
跳过安全检查
3.重新打开终端输入 mysql 直接进入数据库
4.use mysql 切换到mysql数据库,执行 update user set password = password('root') where user = 'root' and host = 'localhost';
如果提示没有 password 这个字段,执行这句话 update user set authentication_string = password('root') where user = 'root' and host = 'localhost';
5.重启服务 net start mysql