忘记mysql root密码

在这里插入图片描述
在这里插入图片描述
停止mysql服务

net stop mysql

输入以下命令:

mysqld --console --skip-grant-tables --shared-memory 

在这里插入图片描述

重开一个命令窗口

mysql -u root -p

不用输入密码,直接回车就可以登录进去
在这里插入图片描述
更新密码

use mysql;  --进入mysql

update user set authentication_string='' where user='root';--将字段置为空

flush privileges;--刷新MySQL的系统权限相关表,否则会被拒绝

ALTER user 'root'@'localhost' IDENTIFIED BY 'yhx524685';--修改密码为123456

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_48652345/article/details/123217193