mysql破解密码
1.设置mysql免密登陆
# vim /etc/my.cnf.d/mysql-server.cnf #主配置文件[mysqld]下面添加以下内容
[mysqld] skip-grant-tables #免密的登陆
#重启mysql
# systemctl restart mysqld
2.查看数据库中用户的密码,此时是加密状态
mysql> select host,user, authentication_string from mysql.user; +-----------+------------------+------------------------------------------------------------------------+ | host | user | authentication_string | +-----------+------------------+------------------------------------------------------------------------+ | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | +-----------+------------------+------------------------------------------------------------------------+ 4 rows in set (0.00 sec)
2.把mysql库下user表中 用户root的密码设置为无;
# mysql #进入mysql
mysql> update mysql.user set authentication_string="" where user="root";
+-----------+------------------+------------------------------------------------------------------------+
| host | user | authentication_string |
+-----------+------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root | |
+-----------+------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)
4.设置mysql中root用户的密码
mysql>alter user root@"localhost" identified by "123"; #密码设置为123
mysql> flush privileges; #使命令生效
mysql> exit;
Bye
5.解除免密登陆
# vim /etc/my.cnf.d/mysql-server.cnf #主配置文件添加以下内容
[mysqld] #skip-grant-tables #注释掉免密的登陆
#重启mysql # systemctl restart mysqld
# mysql -uroot -p123 #使用刚重新设置的密码登陆mysql
标签:+-----------+------------------+------------------------------------------------ From: https://www.cnblogs.com/cndr/p/17611376.html