二进制格式mysql安装和密码破解

https://downloads.mysql.com/archives/community/
选择版本 系统 内核
在这里插入图片描述

[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
debug  kernels  mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# useradd -r -M -s /sbin/nologin mysql
[root@localhost src]# tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# ls
bin  games    lib    libexec                              sbin   src
etc  include  lib64  mysql-5.7.37-linux-glibc2.12-x86_64  share
[root@localhost local]# mv mysql-5.7.37-linux-glibc2.12-x86_64 mysql[root@localhost local]# chown -R mysql.mysql mysql
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 2 root  root    6 622 2021 bin
drwxr-xr-x. 2 root  root    6 622 2021 etc
drwxr-xr-x. 2 root  root    6 622 2021 games
drwxr-xr-x. 2 root  root    6 622 2021 include
drwxr-xr-x. 2 root  root    6 622 2021 lib
drwxr-xr-x. 3 root  root   17 414 01:35 lib64
drwxr-xr-x. 2 root  root    6 622 2021 libexec
drwxr-xr-x. 9 mysql mysql 129 628 19:53 mysql
drwxr-xr-x. 2 root  root    6 622 2021 sbin
drwxr-xr-x. 5 root  root   49 414 01:35 share
drwxr-xr-x. 2 root  root    6 622 2021 src
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/pro
profile    profile.d/ protocols  
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/pro
profile    profile.d/ protocols  
[root@localhost local]# source /etc/profile.d/mysql.sh 
[root@localhost local]# cd mysql/
[root@localhost mysql]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@localhost mysql]# vi /etc/ld.so.conf.d/mysql.conf
[root@localhost mysql]# cat /etc/ld.so.conf.d/mysql.conf 
/usr/local/mysql/lib
[root@localhost mysql]# ldconfig 
[root@localhost mysql]# vi /etc/man_db.conf 
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll /opt/
总用量 0
drwxr-xr-x. 2 mysql mysql 6 628 20:28 data
[root@localhost ~]# which mysqld
/usr/local/mysql/bin/mysqld
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/
2022-06-28T12:32:43.645263Z 0 [Warning] TIMESTAMP with implicit DEFAULT v
alue is deprecated. Please use --explicit_defaults_for_timestamp server o
ption (see documentation for more details).
2022-06-28T12:32:43.972293Z 0 [Warning] InnoDB: New log files created, LS
N=45790
2022-06-28T12:32:44.060583Z 0 [Warning] InnoDB: Creating foreign key cons
traint system tables.
2022-06-28T12:32:44.082487Z 0 [Warning] No existing UUID has been found, 
so we assume that this is the first time that this server has been starte
d. Generating a new UUID: 68aa937b-f6de-11ec-ae3a-000c290ce3a6.
2022-06-28T12:32:44.083725Z 0 [Warning] Gtid table is not ready to be use
d. Table 'mysql.gtid_executed' cannot be opened.
2022-06-28T12:32:45.184396Z 0 [Warning] A deprecated TLS version TLSv1 is
 enabled. Please use TLSv1.2 or higher.
2022-06-28T12:32:45.184441Z 0 [Warning] A deprecated TLS version TLSv1.1 
is enabled. Please use TLSv1.2 or higher.
2022-06-28T12:32:45.185445Z 0 [Warning] CA certificate ca.pem is self sig
ned.
2022-06-28T12:32:45.314765Z 1 [Note] A temporary password is generated fo
r root@localhost: =,Hw=astd5+.
[root@localhost ~]# vi /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf 
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
#sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DI
VISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@localhost support-files]# file mysql.server 
mysql.server: POSIX shell script, ASCII text executable
[root@localhost support-files]# ll
总用量 24
-rw-r--r--. 1 mysql mysql   773 1130 2021 magic
-rwxr-xr-x. 1 mysql mysql  1061 1130 2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql   894 1130 2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 1130 2021 mysql.server
[root@localhost support-files]# cp mysql.server mysqld
[root@localhost support-files]# ll
总用量 36
-rw-r--r--. 1 mysql mysql   773 1130 2021 magic
-rwxr-xr-x. 1 root  root  10576 628 20:44 mysqld
-rwxr-xr-x. 1 mysql mysql  1061 1130 2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql   894 1130 2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 1130 2021 mysql.server
[root@localhost support-files]# chown -R mysql.mysql mysqld
[root@localhost support-files]# ll
总用量 36
-rw-r--r--. 1 mysql mysql   773 1130 2021 magic
-rwxr-xr-x. 1 mysql mysql 10576 628 20:44 mysqld
-rwxr-xr-x. 1 mysql mysql  1061 1130 2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql   894 1130 2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 1130 2021 mysql.server
[root@localhost support-files]# vim mysqld
[root@localhost support-files]# cd
[root@localhost ~]# /usr/local/mysql/support-files/mysqld
mysqld               mysqld_multi.server  
[root@localhost ~]# /usr/local/mysql/support-files/mysql
mysqld               mysql-log-rotate     
mysqld_multi.server  mysql.server         
[root@localhost ~]# /usr/local/mysql/support-files/mysqld 
anaconda-ks.cfg  .bash_profile    .cshrc           .viminfo
.bash_history    .bashrc          .ssh/            .wget-hsts
.bash_logout     .config/         .tcshrc          
[root@localhost ~]# /usr/local/mysql/support-files/mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
 SUCCESS! 
[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q   Local Address:Port   Peer Address:Port Process  
LISTEN  0       128            0.0.0.0:22          0.0.0.0:*             
LISTEN  0       80                   *:3306              *:*             
LISTEN  0       128               [::]:22             [::]:*             
[root@localhost ~]# mysql -uroot -p'=,Hw=astd5+.'
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@localhost ~]# dnf provides libncurses.so.5
[root@localhost ~]# mysql -uroot -p'=,Hw=astd5+.'
mysql> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit



开机自启

[root@localhost ~]# cp /usr/lib/systemd/system/sshd.service mysqld.service
[root@localhost ~]# ls
anaconda-ks.cfg  mysqld.service
[root@localhost ~]# vim mysqld.service 
[root@localhost ~]# setenforce 0
[root@192 ~]# cat /usr/lib/systemd/system/mysqld.service 
[Unit]
Description=mysqld server daemon
After=network.target sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysqld start
ExexStop=/usr/local/mysql/support-files/mysqld stop
ExecReload=/bin/kill -HUP$MAINPID
[Install]
WantedBy=multi-user.target
[root@192 ~]# systemctl status mysqld.service
● mysqld.service - mysql server daemon
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; ven>
   Active: active (running) since Tue 2022-06-28 22:05:11 CST; 5s ago
  Process: 8228 ExecStart=/usr/local/mysql/support-files/mysqld start (c>
 Main PID: 8241 (mysqld_safe)
    Tasks: 28 (limit: 11175)
   Memory: 232.4M
   CGroup: /system.slice/mysqld.service
           ├─8241 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/op>
           └─8455 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql>

628 22:05:10 192.168.183.139 systemd[1]: Starting mysql server daemon>
628 22:05:11 192.168.183.139 mysqld[8228]: Starting MySQL. SUCCESS!
628 22:05:11 192.168.183.139 systemd[1]: Started mysql server daemon.

[root@192 ~]# mysql -uroot -p'123456'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql>  quit
Bye




破解密码

[root@localhost ~]# vim /etc/my.cnf // 添加skip-grant-tables

[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> quit
Bye
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| engine_cost               |
| event                     |
| func                      |
| general_log               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
31 rows in set (0.00 sec)

mysql> select * from user\G
*************************** 1. row ***************************
                  Host: localhost
                  User: root
           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
              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
 password_last_changed: 2022-06-28 21:09:35
     password_lifetime: NULL
        account_locked: N
*************************** 2. row ***************************
                  Host: localhost
                  User: mysql.session
           Select_priv: N
           Insert_priv: N
           Update_priv: N
           Delete_priv: N
           Create_priv: N
             Drop_priv: N
           Reload_priv: N
         Shutdown_priv: N
          Process_priv: N
             File_priv: N
            Grant_priv: N
       References_priv: N
            Index_priv: N
            Alter_priv: N
          Show_db_priv: N
            Super_priv: Y
 Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              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: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
      password_expired: N
 password_last_changed: 2022-06-28 20:32:45
     password_lifetime: NULL
        account_locked: Y
*************************** 3. row ***************************
                  Host: localhost
                  User: mysql.sys
           Select_priv: N
           Insert_priv: N
           Update_priv: N
           Delete_priv: N
           Create_priv: N
             Drop_priv: N
           Reload_priv: N
         Shutdown_priv: N
          Process_priv: N
             File_priv: N
            Grant_priv: N
       References_priv: N
            Index_priv: N
            Alter_priv: N
          Show_db_priv: N
            Super_priv: N
 Create_tmp_table_priv: N
      Lock_tables_priv: N
          Execute_priv: N
       Repl_slave_priv: N
      Repl_client_priv: N
      Create_view_priv: N
        Show_view_priv: N
   Create_routine_priv: N
    Alter_routine_priv: N
      Create_user_priv: N
            Event_priv: N
          Trigger_priv: N
Create_tablespace_priv: N
              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: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE
      password_expired: N
 password_last_changed: 2022-06-28 20:32:45
     password_lifetime: NULL
        account_locked: Y
3 rows in set (0.00 sec)

mysql> update user set authentication_string = password('123') where User = 'root' and Host = 'localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> quit
Bye
[root@localhost ~]# mysql -uroot -p'123'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> quit
Bye
[root@localhost ~]# vim /etc/my.cnf // 删除skip-grant-tables
[root@192 ~]# mysql -uroot -p'123'mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值