All Products
Search
Document Center

PolarDB:SHOW BINLOG EVENTS

Last Updated:Mar 28, 2026

Inspect the contents of a binary log file to debug replication issues, audit data changes, or trace transaction history.

Syntax

SHOW BINLOG EVENTS
   [WITH 'stream_name']
   [IN 'log_name']
   [FROM pos]
   [LIMIT [offset,] row_count]

Prerequisites

Before you run this statement, grant the REPLICATION SLAVE privilege to your account. For details, see Manage accounts and permissions.

Usage notes

  • Without `WITH`: queries events from binary log files generated in single-stream mode.

  • With `WITH 'stream_name'`: queries events from binary log files in multi-stream mode. The stream_name parameter specifies which stream to query.

  • V5.4.18 and later: if you specify a binary log file name, you can query multi-stream binary log events without the WITH parameter.

For the full MySQL reference, see SHOW BINLOG EVENTS.

Output columns

ColumnDescription
LOG_NAMEName of the binary log file.
POSPosition at which the event starts.
EVENT_TYPEType of the event (for example, Query, Write_rows, Xid).
SERVER_IDID of the server where the event originated.
END_LOG_POSPosition where the next event begins, equal to POS plus the size of the current event.
INFOAdditional details about the event. The format depends on the event type.

Examples

Single-stream mode

Example 1: Query all events

SHOW BINLOG EVENTS;

Output:

+---------------+------+------------+-----------+-------------+--------------------------------------------------------+
| LOG_NAME      | POS  | EVENT_TYPE | SERVER_ID | END_LOG_POS | INFO                                                   |
+---------------+------+------------+-----------+-------------+--------------------------------------------------------+
| binlog.000001 |  745 | Query      |         1 |         807 | BEGIN                                                  |
| binlog.000001 |  807 | Table_map  |         1 |         868 | table_id: 258 (transfer_test.accounts)                 |
| binlog.000001 |  868 | Write_rows |         1 |         912 | table_id: 258 flags: STMT_END_F                        |
| binlog.000001 |  912 | Table_map  |         1 |         973 | table_id: 367 (transfer_test.accounts)                 |
| binlog.000001 |  973 | Write_rows |         1 |        1017 | table_id: 367 flags: STMT_END_F                        |
| binlog.000001 | 1017 | Table_map  |         1 |        1078 | table_id: 366 (transfer_test.accounts)                 |
| binlog.000001 | 1078 | Write_rows |         1 |        1122 | table_id: 366 flags: STMT_END_F                        |
| binlog.000001 | 1122 | Table_map  |         1 |        1183 | table_id: 365 (transfer_test.accounts)                 |
| binlog.000001 | 1183 | Write_rows |         1 |        1227 | table_id: 365 flags: STMT_END_F                        |
| binlog.000001 | 1227 | Table_map  |         1 |        1288 | table_id: 365 (transfer_test.accounts)                 |
| binlog.000001 | 1288 | Write_rows |         1 |        1332 | table_id: 365 flags: STMT_END_F                        |
| binlog.000001 | 1332 | Xid        |         1 |        1363 | COMMIT /* xid=1 */                                     |
| binlog.000001 | 1363 | Rows_query |         1 |        1441 | 677707399066754342413081391897447014400000000000132369 |
+---------------+------+------------+-----------+-------------+--------------------------------------------------------+

Example 2: Query a specific file with pagination

SHOW BINLOG EVENTS IN 'binlog.000010' LIMIT 10,10;

This returns rows 11–20 from binlog.000010. Output:

+---------------+------+------------+------------+-------------+-------------------------------------------------------------+
| LOG_NAME      | POS  | EVENT_TYPE | SERVER_ID  | END_LOG_POS | INFO                                                        |
+---------------+------+------------+------------+-------------+-------------------------------------------------------------+
| binlog.000010 |  563 | Rows_query | 2381662369 |         606 | # TSO HEARTBEAT TXN                                         |
| binlog.000010 |  606 | Xid        | 2381662369 |         637 | COMMIT /* xid=4649 */                                       |
| binlog.000010 |  637 | Rows_query | 2381662369 |         720 | CTS::718600843552620550417170736510664744970000000000000000 |
| binlog.000010 |  720 | Query      | 2381662369 |         762 | BEGIN                                                       |
| binlog.000010 |  762 | Rows_query | 2381662369 |         805 | # TSO HEARTBEAT TXN                                         |
| binlog.000010 |  805 | Xid        | 2381662369 |         836 | COMMIT /* xid=4650 */                                       |
| binlog.000010 |  836 | Rows_query | 2381662369 |         919 | CTS::718600843643217516817170736519766384640000000000000000 |
| binlog.000010 |  919 | Query      | 2381662369 |         961 | BEGIN                                                       |
| binlog.000010 |  961 | Rows_query | 2381662369 |        1004 | # TSO HEARTBEAT TXN                                         |
| binlog.000010 | 1004 | Xid        | 2381662369 |        1035 | COMMIT /* xid=4651 */                                       |
+---------------+------+------------+------------+-------------+-------------------------------------------------------------+

Example 3: Query starting from a position

SHOW BINLOG EVENTS IN 'binlog.000010' FROM 1004 LIMIT 10,10;

This returns 10 events starting after position 1004 in binlog.000010, skipping the first 10 matches. Output:

+---------------+------+------------+------------+-------------+-------------------------------------------------------------+
| LOG_NAME      | POS  | EVENT_TYPE | SERVER_ID  | END_LOG_POS | INFO                                                        |
+---------------+------+------------+------------+-------------+-------------------------------------------------------------+
| binlog.000010 | 1516 | Query      | 2381662369 |        1558 | BEGIN                                                       |
| binlog.000010 | 1558 | Rows_query | 2381662369 |        1601 | # TSO HEARTBEAT TXN                                         |
| binlog.000010 | 1601 | Xid        | 2381662369 |        1632 | COMMIT /* xid=4654 */                                       |
| binlog.000010 | 1632 | Rows_query | 2381662369 |        1715 | CTS::718600856207674579217170737776170147840000000000000000 |
| binlog.000010 | 1715 | Query      | 2381662369 |        1757 | BEGIN                                                       |
| binlog.000010 | 1757 | Rows_query | 2381662369 |        1800 | # TSO HEARTBEAT TXN                                         |
| binlog.000010 | 1800 | Xid        | 2381662369 |        1831 | COMMIT /* xid=4655 */                                       |
| binlog.000010 | 1831 | Rows_query | 2381662369 |        1914 | CTS::718600868492790995217170739004681789440000000000000000 |
| binlog.000010 | 1914 | Query      | 2381662369 |        1956 | BEGIN                                                       |
| binlog.000010 | 1956 | Rows_query | 2381662369 |        1999 | # TSO HEARTBEAT TXN                                         |
+---------------+------+------------+------------+-------------+-------------------------------------------------------------+

Multi-stream mode

In multi-stream mode, use the WITH 'stream_name' clause to target a specific stream. The LOG_NAME in the output uses # as a separator between the stream name and the binlog file name (for example, group1_stream_0#binlog.000001).

Example 4: Query the first events in a multi-stream file

SHOW BINLOG EVENTS WITH 'group1_stream_0' IN 'group1_stream_0_binlog.000001' LIMIT 10;

Output:

+-------------------------------+-----+-------------+------------+-------------+-------------------------------------------------------------+
| LOG_NAME                      | POS | EVENT_TYPE  | SERVER_ID  | END_LOG_POS | INFO                                                        |
+-------------------------------+-----+-------------+------------+-------------+-------------------------------------------------------------+
| group1_stream_0#binlog.000001 |   4 | Format_desc | 2065077497 |         123 | Server ver: 5.6.29-TDDL-5.4.13-16504348, Binlog ver: 4      |
| group1_stream_0#binlog.000001 | 123 | Rows_query  | 2065077497 |         206 | CTS::692310358647373830414541688019972300810000000000640450 |
| group1_stream_0#binlog.000001 | 206 | Rows_query  | 2065077497 |         289 | CTS::692310358730001619214541688028360949770000000000640450 |
| group1_stream_0#binlog.000001 | 289 | Rows_query  | 2065077497 |         372 | CTS::692310358815145990414541688036749516810000000000640450 |
| group1_stream_0#binlog.000001 | 372 | Rows_query  | 2065077497 |         455 | CTS::692310358897773779214541688045138165770000000000640450 |
| group1_stream_0#binlog.000001 | 455 | Rows_query  | 2065077497 |         538 | CTS::692310358982498720014541688053526732810000000000640450 |
| group1_stream_0#binlog.000001 | 538 | Rows_query  | 2065077497 |         621 | CTS::692310371229027539214541689278263541770000000000640450 |
| group1_stream_0#binlog.000001 | 621 | Rows_query  | 2065077497 |         704 | CTS::692310371313333049614541689286652108810000000000640450 |
| group1_stream_0#binlog.000001 | 704 | Rows_query  | 2065077497 |         787 | CTS::692310371397219129614541689295040757770000000000640450 |
| group1_stream_0#binlog.000001 | 787 | Rows_query  | 2065077497 |         870 | CTS::692310371481105209614541689303429324810000000000640450 |
+-------------------------------+-----+-------------+------------+-------------+-------------------------------------------------------------+

Example 5: Query from a position in a multi-stream file

SHOW BINLOG EVENTS WITH 'group1_stream_0' IN 'group1_stream_0_binlog.000010' FROM 285948 LIMIT 10,10;

Output:

+-------------------------------+--------+-------------+-----------+-------------+------------------------------------------------------------------------------------------------------------------+
| LOG_NAME                      | POS    | EVENT_TYPE  | SERVER_ID | END_LOG_POS | INFO                                                                                                             |
+-------------------------------+--------+-------------+-----------+-------------+------------------------------------------------------------------------------------------------------------------+
| group1_stream_0_binlog.000010 | 286661 | Rows_query  |    181818 |      286744 | CTS::718609494295393081617171601585109770270000000000000000                                                      |
| group1_stream_0_binlog.000010 | 286744 | Query       |    181818 |      286786 | BEGIN                                                                                                            |
| group1_stream_0_binlog.000010 | 286786 | Rows_query  |    181818 |      286922 | /*DRDS /10.1.38.30/17d49410f7801001-4/0/181818/ */
# CTS::718609494297490233617171601585277542410000000000000000 |
| group1_stream_0_binlog.000010 | 286922 | Table_map   |    181818 |      286995 | table_id: 1 (cdc_transfer_test.binlogx_accounts)                                                                 |
| group1_stream_0_binlog.000010 | 286995 | Update_rows |    181818 |      287049 | table_id: 1                                                                                                      |
| group1_stream_0_binlog.000010 | 287049 | Xid         |    181818 |      287080 | COMMIT /* xid=584 */                                                                                             |
| group1_stream_0_binlog.000010 | 287080 | Rows_query  |    181818 |      287163 | CTS::718609494297490233617171601585277542410000000000000000                                                      |
| group1_stream_0_binlog.000010 | 287163 | Query       |    181818 |      287205 | BEGIN                                                                                                            |
| group1_stream_0_binlog.000010 | 287205 | Rows_query  |    181818 |      287341 | /*DRDS /10.1.38.30/17d49410f9801001-2/0/181818/ */
# CTS::718609494300845676817171601585613086730000000000000000 |
| group1_stream_0_binlog.000010 | 287341 | Table_map   |    181818 |      287414 | table_id: 1 (cdc_transfer_test.binlogx_accounts)                                                                 |
+-------------------------------+--------+-------------+-----------+-------------+------------------------------------------------------------------------------------------------------------------+

Example 6: Query multi-stream events without WITH (V5.4.18 and later)

On PolarDB-X instances running kernel version V5.4.18 or later, specifying the binary log file name is sufficient to query multi-stream events — the WITH parameter is not required.

SHOW BINLOG EVENTS IN 'group1_stream_0_binlog.000003' LIMIT 10;

Output:

+-------------------------------+------+-------------+------------+-------------+----------------------------------------------------------------------------------------------------------+
| LOG_NAME                      | POS  | EVENT_TYPE  | SERVER_ID  | END_LOG_POS | INFO                                                                                                     |
+-------------------------------+------+-------------+------------+-------------+----------------------------------------------------------------------------------------------------------+
| group1_stream_0_binlog.000003 |    4 | Format_desc | 2381662369 |         123 | Server ver: 5.6.29-TDDL-5.4.18-SNAPSHOT, Binlog ver: 4                                                   |
| group1_stream_0_binlog.000003 |  123 | Query       | 2381662369 |         165 | BEGIN                                                                                                    |
| group1_stream_0_binlog.000003 |  165 | Rows_query  | 2381662369 |         293 | /*DRDS /10.2.29.72/17d44302a2001000/0// */
# CTS::718600582101100140817170710365219102720000000000000000 |
| group1_stream_0_binlog.000003 |  293 | Table_map   | 2381662369 |         424 | table_id: 184 (drds_polarx1_part_qatest_app.update_delete_base_broadcast)                                |
| group1_stream_0_binlog.000003 |  424 | Write_rows  | 2381662369 |         552 | table_id: 184                                                                                            |
| group1_stream_0_binlog.000003 |  552 | Write_rows  | 2381662369 |         685 | table_id: 184                                                                                            |
| group1_stream_0_binlog.000003 |  685 | Write_rows  | 2381662369 |         821 | table_id: 184                                                                                            |
| group1_stream_0_binlog.000003 |  821 | Write_rows  | 2381662369 |         960 | table_id: 184                                                                                            |
| group1_stream_0_binlog.000003 |  960 | Xid         | 2381662369 |         991 | COMMIT /* xid=8387 */                                                                                    |
| group1_stream_0_binlog.000003 |  991 | Rows_query  | 2381662369 |        1074 | CTS::718600582101100140817170710365219102720000000000000000                                              |
+-------------------------------+------+-------------+------------+-------------+----------------------------------------------------------------------------------------------------------+