centos7 mysql忘记密码重置密码

1.添加配置

vim /etc/my.cnf

添加如下内容:

添加一条:skip-grant-tables

centos7 mysql忘记密码重置密码

:wq保存退出

2.重启mysql:service mysqld start

centos7 mysql忘记密码重置密码

3.直接输入:mysql,无密码的登陆进去

centos7 mysql忘记密码重置密码

4.use mysql

centos7 mysql忘记密码重置密码

5.update mysql.user set authentication_string=password('这里输入你的密码') where user='root' and Host ='localhost';

centos7 mysql忘记密码重置密码

密码修改成功!