Loading

MYSQL8.0 忘记密码

1、关闭MySQL服务,以管理员身份运行cmd,输入net stop MySQL(服务名) 

2、跳过权限验证,mysqld --console --skip-grant-tables --shared-memory

3、以管理员身份运行cmd,新开一个命令行窗口,mysql -uroot –p

4、要求输入密码时,直接回车进行登录,将登录密码置空

# 1.使用mysql库
use mysql;

# 2.将root账号密码修改空字符
update user set authentication_string='' where user='root';

# 3.退出
exit;

5、修改密码注意事项

需要将执行语句 mysqld --console --skip-grant-tables --shared-memory 的窗口关闭,再重新启动mysql服务。

6、无密码登录修改密码,执行语句修改密码

alter user 'root'@'localhost' identified by 'root';
posted @ 2022-09-21 23:22  三淼  阅读(177)  评论(0编辑  收藏  举报