一.问题:

太久没用mysql ,忘记了原先的root密码

二:解决

1.关闭mysql服务

2.使用cd指令切换到mysql的bin目录

使用mysqld –console –skip-grant-tables –shared-memory如下图.

3.打开一个新的cmd窗口,

mysql -u root -p发现可直接enter键不输入密码进入mysql操作界面,如下图

4.使用名为mysql的数据库,将对应user表的密码置空

如下图

5. 关闭以步骤2mysqld –console –skip-grant-tables –shared-memory打开的mysql服务(直接关掉窗口即可)

6. 重新开启mysql服务,实现无密码登陆了

7.修改密码

注意root和localhost的引号需为英文字符

alter user 'root'@'localhost'identified with mysql_native_password by 'xxx';//xxx为新密码
flush privileges

重新进入mysql就需要输入刚刚前面设置的新密码了。

总结

到此这篇关于mysql8.0忘记密码的详细解决方法的文章就介绍到这了,更多相关mysql8.0 忘记密码解决内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!