SHOW BINARY LOGS lists the binary log files on a PolarDB-X instance, along with their sizes and metadata. Use this statement to inspect available logs before purging them or diagnosing replication issues.
Prerequisites
Before you run this statement, make sure your account has the SUPER or REPLICATION CLIENT privilege. To manage account privileges, see Manage accounts and permissions.
Syntax
SHOW [FULL] BINARY LOGS [WITH 'stream_name']Usage notes
Without the
WITHclause, the statement returns binary log files generated in single-stream mode.With
WITH 'stream_name', the statement returns binary log files for the specified stream in multi-stream mode. Replacestream_namewith the name of the target stream.The
FULLkeyword is available for instances running kernel version V5.4.18 or later. It returns additional metadata columns for each log file.For the MySQL reference, see SHOW BINARY LOGS.
Examples
Single-stream mode
SHOW BINARY LOGS;Result:
+---------------+-----------+
| LOG_NAME | FILE_SIZE |
+---------------+-----------+
| binlog.000001 | 4 |
+---------------+-----------+Multi-stream mode
SHOW BINARY LOGS WITH 'group1_stream_0';Result:
+-------------------------------+-----------+
| LOG_NAME | FILE_SIZE |
+-------------------------------+-----------+
| group1_stream_0#binlog.000001 | 3626808 |
+-------------------------------+-----------+In multi-stream mode, LOG_NAME is prefixed with the stream name, making it easy to identify which stream each file belongs to.
Full output (kernel V5.4.18 and later)
show full binary logs \G;Result:
*************************** 1. row ***************************
LOG_NAME: binlog.000001
FILE_SIZE: 20968
CREATE_TIME: 2024-04-15 21:34:47
LAST_MODIFY_TIME: 2024-04-15 21:36:01
FIRST_EVENT_TIME: 2024-04-15 21:35:46
LAST_EVENT_TIME: 2024-04-15 21:35:54
LAST_TSO: 718563192765363001617166971431561502720000000000000000
UPLOAD_STATUS: SUCCESS
FILE_LOCATION: REMOTE
EXTINFO:The FULL keyword returns these additional columns:
| Column | Description |
|---|---|
CREATE_TIME | Time the binary log file was created |
LAST_MODIFY_TIME | Time the binary log file was last modified |
FIRST_EVENT_TIME | Execution time of the first SQL statement recorded in the file |
LAST_EVENT_TIME | Execution time of the last SQL statement recorded in the file |
LAST_TSO | TSO of the last transaction in the binary log files |
UPLOAD_STATUS | Upload status of the file. SUCCESS means the file has been uploaded to remote storage for archiving. |
FILE_LOCATION | Where the file currently resides. See the table below. |
EXTINFO | Additional information |
FILE_LOCATION has two possible values:
| Value | Meaning |
|---|---|
LOCAL | The file is stored on local disk. If UPLOAD_STATUS is SUCCESS, a copy also exists in remote storage. |
REMOTE | The file is stored in remote storage, not on local disk. |