mysql忘记root密码

发布时间 2023-09-05 09:09:25作者: 燚林

mysql忘记root密码并修改:

1、绕过密码验证

修改msyql配置文件
[mysqld] 下添加skip-grant-tables        ##跳过授权表

2、重启mysql服务
3、登录mysql,use进入mysql库,修改user表

修改root密码
update user set authentication_string = '123' where  user = 'root' and host = 'localhost'                 ##明文密码
update user set authentication_string = password('123') where user = 'root' and host = 'localhost'            ##密文密码

4、删除mysql配置文件中跳过授权表的操作,并重启数据库验证。