目录
1、进程的关系
在mysql里查看有哪些用户登录
show processlist;
2、密码破解
2.1 不同用户
(1)超级用户root@localhost
- 只能在本地登录
- 修改/etc/my.cnf skip-grant-tables
- 使用另外一个管理员账户去修改'root'@'localhost'
alter user 'root'@'localhost' identified by '123456';
- 修改停止mysql服务,需要中断业务
(2)其他的普通用户
- alter user 'cali'@'%' identified by 'Sanchuang123#';
- 使用超级用户登录,直接去修改密码就可以了
2.2 破解MySQL的密码
第一步:停止MySQL进程的运行
[root@localhost ~]# service mysql stop
Redirecting to /bin/systemctl stop mysql.service
[root@localhost ~]# ps aux|grep mysqld
root 1748 0.0 0.0 112824 984 pts/2 R+ 21:40 0:00 grep --color=auto mysqld
第二步:修改配置文件
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
skip-grant-tables 跳过密码验证
第三步:启动MySQL进程
service mysql start
第四步:登录mysql,不接密码
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
root@(none) 21:43 mysql>alter user 'root'@'localhost' identified by 'Sanchuang1234#';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
root@(none) 21:49 mysql>flush privilieges; 刷新权限(会加载原来没有加载的权限表 --》用户名和密码所在的表user等)
root@(none) 21:50 mysql>alter user 'root'@'localhost' identified by 'Sanchuang123#';
Query OK, 0 rows affected (0.00 sec)
root@(none) 21:52 mysql>quit
Bye
第五步:重新修改mysql的配置文件
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
#skip-grant-tables 跳过密码验证 注释掉
第六步:刷新服务
[root@localhost ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service
第七步:验证修改密码是否成功
方法二:
使用其他的管理员账号给别的用户重新设置密码
可以在SQLyog里操作
SET PASSWORD FOR 'root'@'localhost' = 'Sanchuang123#';
alter user 'root'@'localhost' identified by 'Sanchuang123#';
连接匹配原则:
当用户名相同时,优先精准匹配登录
root@%
会优先匹配第二个用户