1.以管理员身份运行cmd,关闭mysql服务
net stop mysql80
2.跳过密码输入授权
mysqld --console --skip-grant-tables --shared-memory
3.再打开一个cmd窗口,重置密码
### 执行命令 : mysql
### 执行命令 : use mysql(进入msql这个数据库)
### 查看一下数据 : select user,authentication_string,host from user;
update user set authentication_string='123456' where user='root' and host='localhost';
4.关闭这两个cmd窗口,重新打开一个
net start mysql
mysql -uroot -p
出现错误试一下 关闭MySQL 跳过权限
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
然后授予权限:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
net start mysql
mysql -uroot -p