mysql数据库5.7版本二进制安装与破解mysql数据库密码

mysql二进制安装与密码破解

1:二进制安装

进入包存放的路径


[root@localhost src]# cd /usr/src/

创建mysql的用户


[root@localhost src]# useradd -M -r -s /sbin/nologin mysql
[root@localhost src]# id mysql
uid=975(mysql) gid=974(mysql) 组=974(mysql)

将安装包解压至/usr/local


[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  etc  games  include  lib  lib64  libexec  mysql-5.7.37-linux-glibc2.12-x86_64  sbin  share  src
[root@localhost local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.37-linux-glibc2.12-x86_64/'
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 2 root root   6 6月  22 2021 bin
drwxr-xr-x. 2 root root   6 6月  22 2021 etc
drwxr-xr-x. 2 root root   6 6月  22 2021 games
drwxr-xr-x. 2 root root   6 6月  22 2021 include
drwxr-xr-x. 2 root root   6 6月  22 2021 lib
drwxr-xr-x. 3 root root  17 3月   6 20:08 lib64
drwxr-xr-x. 2 root root   6 6月  22 2021 libexec
lrwxrwxrwx. 1 root root  36 7月  26 18:40 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 7月  26 18:37 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 6月  22 2021 sbin
drwxr-xr-x. 5 root root  49 3月   6 20:08 share
drwxr-xr-x. 2 root root   6 6月  22 2021 src
[root@localhost local]# 

修改目录/usr/local/mysql的属主属组


[root@localhost local]# chown -R mysql.mysql mysql
[root@localhost local]# ll mysql -d
lrwxrwxrwx. 1 mysql mysql 36 7月  26 18:40 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/

编写环境变量


[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# . /etc/profile.d/mysql.sh
[root@localhost local]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

将mysql的头文件输出给系统


[root@localhost mysql]# ln -s  /usr/local/mysql/include  /usr/include/mysql
root@localhost mysql]# ll  /usr/include/
总用量 0
drwxr-xr-x. 4 root root 34 3月   6 20:13 gnome-boxes
lrwxrwxrwx. 1 root root 24 7月  26 18:46 mysql -> /usr/local/mysql/include

配置man帮助手册


[root@localhost mysql]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/local/mysql/man

增添额外库文件

[root@localhost mysql]# echo '/var/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf 
[root@localhost mysql]# ldconfig

建立数据存放目录


[root@localhost mysql]# mkdir /opt/data
[root@localhost mysql]# chown -R mysql.mysql /opt/data/
[root@localhost mysql]# ll /opt/
总用量 0
drwxr-xr-x. 2 mysql mysql 6 7月  26 18:58 data

初始化数据库


[root@localhost mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2022-07-26T10:59:26.939711Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-26T10:59:27.097891Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-26T10:59:27.122982Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-26T10:59:27.127555Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 043007c0-0cd2-11ed-b67d-000c295a7a3f.
2022-07-26T10:59:27.128074Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-26T10:59:27.670720Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-26T10:59:27.670745Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-26T10:59:27.671135Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-26T10:59:27.803704Z 1 [Note] A temporary password is generated for root@localhost: 9p4#<?1ipRus

生成配置文件


[root@localhost mysql]# vim /etc/my.cnf
[root@localhost mysql]# 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_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

配置服务启动脚本

[root@localhost mysql]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# vim /etc/init.d/mysqld 
basedir=/usr/local/mysql
datadir=/opt/data

启动mysql


[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL SUCCESS! 
[root@localhost ~]# ps -ef | grep mysql
root        2787       1  0 19:06 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pid
mysql       2987    2787  0 19:06 ?        00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/opt/data/mysql.pid --socket=/tmp/mysql.sock --port=3306
root        7158    2251  0 19:08 pts/0    00:00:00 grep --color=auto mysql
[root@localhost ~]# ss -antl
State                    Recv-Q                   Send-Q                                     Local Address:Port                                       Peer Address:Port                   Process                   
LISTEN                   0                        128                                              0.0.0.0:111                                             0.0.0.0:*                                                
LISTEN                   0                        32                                         192.168.122.1:53                                              0.0.0.0:*                                                
LISTEN                   0                        128                                              0.0.0.0:22                                              0.0.0.0:*                                                
LISTEN                   0                        5                                              127.0.0.1:631                                             0.0.0.0:*                                                
LISTEN                   0                        80                                                     *:3306                                                  *:*                                                
LISTEN                   0                        128                                                 [::]:111                                                [::]:*                                                
LISTEN                   0                        128                                                 [::]:22                                                 [::]:*                                                
LISTEN                   0                        5                                                  [::1]:631                                                [::]:*                                                
[root@localhost ~]# 

2:破解密码

向mysql配置文件my.cnf中添加免除授权

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




添加后报错缺少东西那就去下

root@localhost mysql]# mysql
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@localhost mysql]# dnf -y install libncurses.so.5*
上次元数据过期检查:1:01:05 前,执行于 2022年07月26日 星期二 18时49分17秒。
依赖关系解决。
已安装:
  ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                                                                                                                                                     

完毕!

再次登录

[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> 



修改mysql数据库root密码,并刷新权限

mysql>  update user set  authentication_string:=password ('XUANning@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> flush privileges;
Query OK, 0 rows affected (0.01 sec)

删掉配置文件里的跳过授权使用我们新修改的密码登录mysql,破解密码成功


[root@localhost ~]# vim /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_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[root@localhost ~]# mysql -uroot -pXUANning@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

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
    评论
要进行MySQL 5.7二进制安装,可以按照以下步骤进行操作: 1. 首先,将MySQL二进制包解压到/usr/local目录下。你可以使用以下命令: ``` tar xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ ``` 2. 接下来,配置启动文件并启动MySQL。你可以使用以下命令: ``` cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on service mysqld start ``` 3. 然后,需要初始化MySQL。根据你的操作系统不同,可以使用不同的命令进行安装。如果是CentOS系统,使用以下命令: ``` cd /usr/local/mysql yum -y install libaio* ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/mydata/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp ``` 如果是Ubuntu系统,使用以下命令: ``` cd /usr/local/mysql apt-get -y install libaio-dev ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/mydata/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp ``` 这些步骤将会安装并初始化MySQL 5.7二进制版本。请确保按照指定的路径和命令进行操作,以确保安装过程顺利完成。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [MySQL5.7 二进制安装](https://blog.csdn.net/weixin_68330286/article/details/124588446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值