1.首先停止mysql服务 net stop mysql
2.进入到mysql安装目录执行 mysqld --skip-grant-tables 跳过安全检查
3.重新打开终端输入 mysql 直接进入数据库
4.use mysql 切换到mysql数据库,执行 update user set password = password('root') where user = 'root' and host = 'localhost'; 如果提示没有 password 这个字段,执行这句话 update user set authentication_string = password('root') where user = 'root' and host = 'localhost';
5.重启服务 net start mysql
mysql数据库忘记密码,重置密码
最新推荐文章于 2025-11-27 13:57:04 发布
该博客详细介绍了如何在MySQL中重置root用户的密码。首先通过netstopmysql命令停止服务,然后使用mysqld--skip-grant-tables跳过权限检查进入数据库。接着切换到mysql库,并更新root用户的password或authentication_string字段为新密码。最后,重启MySQL服务使更改生效,命令为netstartmysql。
1142

被折叠的 条评论
为什么被折叠?



