Help Center/ TaurusDB/ User Guide/ Log Management/ Binlog Management/ Obtaining Binlogs Using mysqlbinlog
Updated on 2026-06-09 GMT+08:00

Obtaining Binlogs Using mysqlbinlog

Scenarios

This section describes how to obtain binlogs from an ECS and use the mysqlbinlog tool to view and decode the binlogs.

Prerequisites

You have enabled binlogs, including binlogs stored within an instance and binlogs transferred to OBS.

Procedure

  1. Install the mysql client on the ECS. For details, see How Can I Install a MySQL Client?

    TaurusDB is compatible with MySQL Community Edition 8.0 or later. Do not install the client of a version earlier than 8.0.

  2. Connect to a TaurusDB instance through mysql.
  3. Run the following command to search for the binlogs to be downloaded:
    show binary logs with time;

    If there are too many binlogs, the execution time will increase, which may temporarily block normal transaction commits.

  4. Download the original binlogs to a local PC.

    This section uses Linux as an example. Before running the following statement to download the binlogs to a local PC, run the exit command to exit the mysql client.

    mysqlbinlog -h<connection-address> -u<username> -P<port> -p<password> --read-from-remote-server --raw binlog.xxxx -r <result-file-directory>
    mysqlbinlog -h127.0.0.1 -uroot -P54855 -p --read-from-remote-server --raw binlog.000002 -r /tmp/

    Table 1 mysqlbinlog parameters

    Parameter

    Description

    -h

    Private or public IP address of the TaurusDB instance.

    -u

    Database account of the TaurusDB instance. The default administrator account is root.

    -P

    Database port of the TaurusDB instance. The default value is 3306.

    -p

    Password for logging in to the database of the TaurusDB instance.

    -R (--read-from-remote-server)

    Binlogs are read from a remote server (it is available only when mysqlbinlog and the database server are not on the same computer).

    -r (--result-file)

    Direct output to a given file. If the --raw option is used, the value of this parameter is the prefix of the file names.

  5. Decode the original binlogs.
    mysqlbinlog -vv --base64-output=decode-rows mysql-bin.****** -r <result-file>
    mysqlbinlog -vv --base64-output=decode-rows /tmp/binlog.000002 -r /tmp/000002.result

    Table 2 Decoding parameters

    Parameter

    Description

    -vv

    Displays SQL statements and remarks.

    --base64-output

    Decodes binlogs.

Other mysqlbinlog Parameters

Table 3 mysqlbinlog parameters

Parameter

Description

--start-position

Position where the decoding starts.

--start-datetime

Time when the decoding starts.

--stop-position

Position where the decoding stops.

--stop-datetime

Time where the decoding stops.

--skip-gtids

gtid_log_event is not printed.

--short-form

Only statements are displayed.