linux中mysql忘记root密码,重置密码

1、修改 /etc/my.cnf 配置文件

   vim /etc/my.cnf 添加 skip-grant-tables

linux中mysql忘记root密码,重置密码

 

2、重启mysql服务

service mysqld restart

3、输入用户,直接回车进去

linux中mysql忘记root密码,重置密码

 

4、进入mysql数据库

linux中mysql忘记root密码,重置密码

5、修改密码

update user set authentication_string=password("new password") WHERE user='root' ' and host = 'localhost';

6、去除第一步中的配置 skip-grant-tables,重启mysql服务就好了