Downloading mysqlbinlog
Scenarios
The mysqlbinlog tool is used to parse binlog logs and is contained in the MySQL software package. You can download the MySQL software package of your desired version from the MySQL official website, decompress the package, and obtain the mysqlbinlog tool in the decompressed package. (mysqlbinlog 3.4 maps to MySQL 5.6 and 5.7.) If your mysqlbinlog version is too old to correctly parse MySQL binlogs, perform the following operations.
Procedure
- Download a MySQL software package.
It is recommended that the software package version be the same as your current mysqld major version.
For example, if your MySQL version is 5.7.27, download the following software packages:
- Product Version: 5.7.27
- Operating System: Linux-Generic
The downloaded MySQL software package is mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz.
Figure 1 Download
- Decompress the software package and find the mysqlbinlog tool.
- View the mysqlbinlog tool version.
[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
- Use mysqlbinlog to parse binlogs. The following uses mysql-bin.000001 as an example:
[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*/;
Last Article: Setting a Local Retention Period for MySQL Binlogs
Next Article: Restoring from Backup Files to RDS for MySQL
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.