Mysql密码破解

1首先关闭mysql服务,确保没有任何一个和mysql服务相关的进程开启

systemctl stop mysqld

ps -aux | grep mysql

2把mysql放在后台启动(--skip-grant-table跳过授权表)

mysqld_safe --skip-grant-tables &

3进入mysql(不需要用户名和密码,类似单用户模式)

mysql

show databases;  (查看有哪些数据库)

use mysql  (切换数据库内)

show tables;  (查看有哪些表)

desc user;  (查看这个表有哪些列)(主要找user保存用户位置和authentication_string保存密码位置)

select user,authentication_string from user;  (查看user和authentication_string从user表)

update user set authentication_string =PASSWORD('123456') where user='root';  (更改密码)

flush privileges;  (刷新授权表)

4杀死所有进程(刚才启动方式跳过授权表,不安全)

ps aux | grep mysql  (查看进程)

kill -9 PID  (杀死进程)

5正常启动服务

systemctl start mysqld

原文地址:https://www.cnblogs.com/shinian12138/p/11528467.html