mysql8 密码破解
一、更改配置文件
# systemctl stop mysql
# vim /etc/my.cnf
skip-grant-tables #忽略权限控制表,实现免密登录
二、免密方式启动mysql
# mysqld --skip-grant-tables --user=mysql &
三、进入mysql修改密码
1、清空密码
> update mysql.user set authentication_string='' where user='root';
> FLUSH PRIVILEGES;
2、更新密码
> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; #本地root用户
> ALTER USER 'root'@'%' IDENTIFIED BY '123456'; #远程root用户
> FLUSH PRIVILEGES;
3、退出
> exit
四、重启登录测试
# ps -ef | grep mysql | grep -v grep |xargs kill -9
# systemctl start mysql
# mysql -uroot -p
password: 输入新配置的密码即可登录
附加:
如果服务器firewalld是运行的,记得放行