本篇文件是window环境的mysql8的root密码重置
1、关闭mysql服务
net stop mysql
2、通过没有登录认证的方式启动mysql
mysqld --console --skip-grant-tables --shared-memory
3、重置密码
1)登录mysql
mysql -u root -p
不输入密码直接登录
use mysql
2)查看root的密码是否为空,如果不为空,执行如下,如果为空,直接执行3)
select user,authentication_string from user;
update user set authentication_string='' where user='root';
3)如果上面2)步骤执行查询出来为空,执行如下:
ALTER user 'root'@'localhost' IDENTIFIED BY 'Firedinner123#'; --密码要最少8位+大写字母+小写字母+数字
4、报错情况
如果在执行3-3时出现如下错误,需要刷新回收站:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
flush privileges;