首页 > 代码库 > mysql 忘记root密码

mysql 忘记root密码

1、停止服务:

service mysqld stop

2、修改my.cnf:

1 vim /etc/my.cnf
2 
3 # 添加
4 skip-grant-tables

3、启动服务:

service mysqld start

4、登陆并修改密码:

1 # 登陆数据库
2 mysql
3 # 修改密码
4 update mysql.user  set password=password(newpassword) where user=root

5、密码修改完成后,将my.cnf文件中添加的skip-grant-tables语句注释或删除掉,然后重启数据库即可

 

mysql 忘记root密码