破解root密码和破解mysql密码

文章目录

  • 1. 破解root密码
    • 1.1 启动界面按 e 进入内核
    • 1.2 输入 rd.break
    • 1.3 输入图中的命令
    • 1.4 输入 passwd root 设置新密码
    • 1.5 输入 touch /.autorelabel
    • 1.6 输入两次 exit退出重启
  • 2. 破解mysql密码
    • 2.1 修改配置文件
    • 2.2 无密码登录
    • 2.3 设置新密码
    • 2.4 将配置文件里面添加的内容删除然后重启数据库

1. 破解root密码

1.1 启动界面按 e 进入内核

破解root密码和破解mysql密码_第1张图片

1.2 输入 rd.break

破解root密码和破解mysql密码_第2张图片

1.3 输入图中的命令

破解root密码和破解mysql密码_第3张图片

1.4 输入 passwd root 设置新密码

破解root密码和破解mysql密码_第4张图片

1.5 输入 touch /.autorelabel

这是关于防火墙的一个设置
破解root密码和破解mysql密码_第5张图片

1.6 输入两次 exit退出重启

破解root密码和破解mysql密码_第6张图片

2. 破解mysql密码

2.1 修改配置文件

[root@localhost ~]# vi /etc/my.cnf

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[mysqld]
skip-grant-tables  //加入此行,跳过授权表,跳过权限
//我这里是mariadb,mysql的my.cnf是自己编写的,也是直接加入即可

2.2 无密码登录

[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.27-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| school             |
+--------------------+
4 rows in set (0.001 sec)

2.3 设置新密码

MariaDB [school]> select * from mysql.user\G
*************************** 1. row ***************************
                  Host: localhost
                  User: root
              Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: Y
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
   Delete_history_priv: Y
              ssl_type: 
            ssl_cipher: 
           x509_issuer: 
          x509_subject: 
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9    //修改这个
      password_expired: N
               is_role: N
          default_role: 
    max_statement_time: 0.000000

MariaDB [(none)]> update user set authentication_string = password('123!') where Host = 'localhost' and User = 'root';   

2.4 将配置文件里面添加的内容删除然后重启数据库

[root@localhost ~]# vi /etc/my.cnf

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[mysqld]
skip-grant-tables  //将这个删除,然后保存

你可能感兴趣的:(数据库)