mysql客户端和mysqlbinlog工具安装
# 一、mysqlbinlog工具下载
# mysqlbinlog工具介绍
mysqlbinlog工具用于解析binlog日志,包含在MySQL软件包中。您可在MySQL官网下载对应版本的MySQL软件包,解压并获取解压包中的mysqlbinlog工具(MySQL 5.6和5.7对应的mysqlbinlog版本均为3.4)。由于存在部分客户使用的mysqlbinlog工具版本太旧,无法正确解析MySQL binlog,因此,为您整理了本文,指导您获取最新的mysqlbinlog工具。
# 操作方法
软件下载包地址
MySQL :: Download MySQL Community Server (Archived Versions) (opens new window)
软件下载须知
软件包版本最好与当前您使用的msyqld大版本保持一致。
例如,您本地的MySQL版本为5.7.27,则下载如下版本和系统的软件包:
Product Version:5.7.27
Operating System:Linux-Generic
下载完成后的MySQL软件包名为:mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz。
1
2
3
4
5
2
3
4
5
- 解压软件包,找到mysqlbinlog工具。
- 执行如下命令,查看mysqlbinlog工具的版本信息。
[root@ecs]# tar -zxf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
[root@ecs]# cd mysql-5.7.27-linux-glibc2.12-x86_64/bin
[root@ecs]# ll mysqlbinlog
-rwxr-xr-x 1 7161 31415 11310886 Jun 10 2019 mysqlbinlog
[root@ecs]# ./mysqlbinlog -V
./mysqlbinlog Ver 3.4 for linux-glibc2.12 at x86_64
1
2
3
4
5
6
2
3
4
5
6
3.使用mysqlbinlog工具解析binlog
以解析“mysql-bin.000001”为例:
[root@ecs]# ./mysqlbinlog --no-defaults -vv /root/mysql-bin.000001
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#200316 17:54:14 server id 1 end_log_pos 126 CRC32 0x92b3f2ca Start: binlog v
4, server v 5.7.27-5-debug-log created 200316 17:54:14 at startup
ROLLBACK/*!*/;
BINLOG '
xkxvXg8BAAAAegAAAH4AAAAAAAQANS43LjI3LTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAADGTG9eEzgNAAgAEgAEBAQEEgAAYgAEGggAAAAICAgCAAAACgoKKioAEjQA
Xz0AAcrys5I=
'/*!*/;
# at 126
#200316 17:54:14 server id 1 end_log_pos 157 CRC32 0xfcc47ad6 Previous-GTIDs
# [empty]
# at 157
#200316 17:54:27 server id 1 end_log_pos 204 CRC32 0xa7febd1f Rotate to mysqlbin.
000002 pos: 4
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 二、mysql客户端工具下载
下载软件安装包
mysql-community-common-5.7.22-1.el7.x86_64.rpm
mysql-community-libs-5.7.22-1.el7.x86_64.rpm
mysql-community-client-5.7.22-1.el7.x86_64.rpm
依赖包ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3(按需求下载)
依次安装
rpm-ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm 、
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
yum install mysql-community-client-5.7.22-1.el7.x86_64.rpm
上次更新: 2023/04/21, 08:57:47