MySQL忘记root密码解决方法

MySQL版本:MySQL 5.7

步骤:

# 停止MySQL服务
/etc/rc.d/init/mysqld stop

# 修改配置
# 在[mysqld]配置段下增加skip-grant-tables跳过认证

# 重新启动MySQL
/etc/rc.d/init/mysqld start

# 无需使用密码登录
mysql

# 更新root用户密码
update mysql.user set authentication_string=password('newPassword') where user='root'
原文地址:https://www.cnblogs.com/ioops/p/14313282.html