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
- 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.
- Connect to a TaurusDB instance through mysql.
- 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.
- 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.
- 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
| 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. |
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