废话少说,直接上干货
编辑 vi /etc/my.cnf 加入 skip-grant-tables=1 跳过密码验证 重启服务 systemctl restart mysqld 登录 mysql -uroot -p show databases; use mysql; 切换到mysql数据库,更新 user 表 update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root'; vi /etc/my.cnf 删除 #skip-grant-tables=1 mysql -uroot -proot 重启 mysqld 服务,再用新密码登录即可 |