Using mysqlbinlog to View Binlogs
Scenarios
The mysqlbinlog tool is used to parse binlogs and is contained in the MySQL software package. You can download a MySQL software package of your desired version from the MySQL official website, decompress the package, and obtain the mysqlbinlog tool from the decompressed package (mysqlbinlog 3.4 is for MySQL 5.6 and 5.7). If your mysqlbinlog version is too old to correctly parse binlogs, perform the operations described in this section.
You can also use a third-party tool to parse binlogs for RDS for MySQL.
Procedure
- Download a MySQL software package.
It is recommended that the software package version be the same as your current MySQL major version.
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.
- Find 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*/;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot