- 停止mysqld服务
systemctl stop mysqld
2.在 /etc/my.cnf 配置文件中添加如下配置项,并重启服务
skip-grant-tables=1
3.登陆mysql
mysql
4.修改密码
update mysql.user
set authentication_string=PASSWORD('修改的密码') where user='root' and host='localhost';
5.退出注释掉/etc/my.cnf加入的哪行然后重启mysqld服务
#skip-grant-tables=1
systemctl restart mysqld