centos7 mysql忘记密码重置密码

1.添加配置

vim /etc/my.cnf

添加如下内容:

添加一条:skip-grant-tables

:wq保存退出

2.重启mysql:service mysqld start

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

4.use mysql

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

密码修改成功!