centos7——mysql5.7忘记root密码的处理方式

参考资料:https://www.cnblogs.com/nangch/p/5521193.html

解决方法:

一、通过编辑/etc/my.cnf文件在[mysqld]下面加上skip-grant-tables=1,保存退出;

二、重启MySql服务【systemctl restart mysqld.service】;

三、以root身份登录MySql【mysql -u root】;

四、进入mysql数据库【mysql>   use mysql;】;

五、修改root密码:

mysql> update user set authentication_string = password('新密码'),password_last_changed=now() where user='root';

六、退出mysql,再次编辑/etc/my.cnf文件,将第一步中添加的skip-grant-tables=1删掉,重启启动MySql服务即可。

原文地址:https://www.cnblogs.com/shea/p/8075012.html