MySQL忘记密码后重置密码
1️⃣ 修改配置越过登录
step1:找到配置文件my.ini
在安装目录下找到文件
my.ini
step2:修改配置
在
[mysqld]
下面增加skip-grant-tables
(该指令的意思是跳过授权表)
step3:使用管理员身份打开CMD
step4:重启mysql服务
执行
net stop mysql
命令 ,停止mysql服务
执行net start mysql
命令 ,启动mysql服务
2️⃣登录mysql
执行命令
mysql -uroot -p
回车
输入密码时,直接回车,就可以登录mysql了
3️⃣重置密码
step1:切换数据库到mysql
库
执行
use mysql
回车
step2:重置root用户的密码
执行
update user set authentication_string = '123456' where user = 'root';
将root
用户的密码设置为123456
step3:刷新权限
执行
flush privileges;
刷新权限