MySQL数据库

MySql破解密码(破解方式一:需要重启数据库服务)

2023-01-19  本文已影响0人  技术老男孩

一、破解思路:

二、实操:

第一步:修改主配置文件,并重启服务

[root@host50 ~]# vim /etc/my.cnf
[mysqld]
# 在这行下方添加
# 实现连接服务不需要输入用户名和密码
skip-grant-tables
# 保存退出  
:wq
[root@host50 ~]# systemctl restart mysqld

第二步:登录数据库,修改密码

# 无密码登录
[root@host50 ~]# mysql  

# 修改管理员root 本机登陆密码为666…QQQa
mysql> update  mysql.user set authentication_string=password("666…QQQa") 
where user="root" and host="localhost";  

# 刷新,确保修改生效
mysql> flush privileges;  
# 查询mysql.user表的数据是否更新
mysql> select host,user,authentication_string from mysql.user 
where  user="root"  and  host="localhost";

# 确认没问题后,断开连接
mysql> exit; 

第三步:还原配置文件重启服务

[root@host50 ~]# vim /etc/my.cnf  
[mysqld]
#skip-grant-tables
:wq
[root@host50 ~]# systemctl restart mysqld 
[root@host50 ~]# mysql  -uroot -p666…QQQa
mysql>      
上一篇 下一篇

猜你喜欢

热点阅读