破解mysql用户密码:
1、在my.cnf中添加跳过授权表命令:
vi /etc/my.cnf
skip-grant-tables
注意:密码强度策略要打开。
2、重启mysql:
systemctl restart mysqld
3、登录mysql:(此时可直接登录,不需要密码)
mysql
3、进入mysql后输入以下命令进行修改密码:
show databases;
select * from user\G ;
update user set authentication_string=password('密码') where user='root' and Host='localhost';
4、重新加载系统权限表:
flush privileges;
5、修改完成后,删除配置项:
vi /etc/my.cnf
skip-grant-tables