Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysqlbinlog usage

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Version number: mysqlbinlog Ver 3.4for linux-glibc2.5 at x86x64

Usage: mysqlbinlog-option-option-option.. Mysqlbinlog.00001 mysqlbinlog.00002....

Usage: mysqlbinlog [options] log-files

-?-- help Display this help and exit.

When the base64-output=name log format is in row mode, you need to add this parameter to escape before you can understand it.

Note: this option is only used for viewing, troubleshooting, etc. This parameter cannot be added when the data is really recovered.

Generally used with-vv

-- bind-address=name IP address to bind to.

-- character-sets-dir=name

Directory for character set files.

-d,-- database=name List entries for just this database (local log only).

-- debug-check Check memory and open file usage at exit.

-- debug-info Print some debug info at exit.

-- default-auth=name Default authentication client-side plugin to use.

-D,-- disable-log-bin

Disable binary log. This is useful, if you enabled

-- to-last-log and are sending the output to the same

MySQL server. This way you could avoid an endless loop.

You would also like to use it when restoring after a

Crash to avoid duplication of the statements you already

Have. NOTE: you will need a SUPER privilege to use this

Option.

-F,-- force-if-open Force if binlog was not closed properly.

(Defaults to on; use-skip-force-if-open to disable.)

-f,-- force-read Force reading unknown binlog events.

-H,-- hexdump Augment output with hexadecimal and ASCII event dump.

-h,-- host=name Get the binlog from server.

-l,-- local-load=name

Prepare local temporary files for LOAD DATA INFILE in the

Specified directory.

-o,-- offset=# Skip the first N entries.

-p,-- password [= name]

Password to connect to remote server.

-- plugin-dir=name Directory for client-side plugins.

-P,-- port=# Port number to use for connection or 0 for default to, in

Order of preference, my.cnf, $MYSQL_TCP_PORT

/ etc/services, built-in default (3306).

-- protocol=name The protocol to use for connection (tcp, socket, pipe

Memory).

-R,-- read-from-remote-server reads binlog information from a remote server. Without this option, all remote connection options such as-h-u-p are ignored and will become a local read of your own defined mysql-binlog.

Read binary logs from a MySQL server. This is an alias

For read-from-remote-master=BINLOG-DUMP-NON-GTIDS.

-- read-from-remote-master=name

Read binary logs from a MySQL server through the

COM_BINLOG_DUMP or COM_BINLOG_DUMP_GTID commands by

Setting the option to either BINLOG-DUMP-NON-GTIDS or

BINLOG-DUMP-GTIDS, respectively. If

-- read-from-remote-master=BINLOG-DUMP-GTIDS is combined

With-- exclude-gtids, transactions can be filtered out on

The master avoiding unnecessary network traffic.

-- raw Requires-R.

When remote backup of binlog needs to be enabled, the binary file Output raw binlog data instead of SQL is generated.

Statements, output is to log files.

-r,-- result-file=name

When backing up remotely, specify the directory where the backup is located locally

/ backup/mysql-bin

Direct output to a given file. With-raw this is a

Prefix for the file names.

-- secure-auth Refuse client connecting to server if it uses old

(pre-4.1.1) protocol.

(Defaults to on; use-skip-secure-auth to disable.)

-- server-id=# Extract only binlog entries created by the server having

The given id.

-- server-id-bits=# Set number of significant bits in server-id

-- set-charset=name Add 'SET NAMES character_set' to the output.

-s,-- short-form Just show regular queries: no extra info and no row-based

Events. This is for testing only, and should not be used

In production systems. If you want to suppress

Base64-output, consider using-- base64-output=never

Instead.

-S,-- socket=name The socket file to use for connection.

-- start-datetime=name

Start point in time, start scanning from the first file specified, "= log at this point in time

Start reading the binlog at first event having a datetime

Equal or posterior to the argument; the argument must be

A date and time in the local time zone, in any format

Accepted by the MySQL server for DATETIME and TIMESTAMP

Types, for example: 2004-12-25 11:25:56 (you should

Probably use quotes for your shell to set it properly).

-J,-- start-position=#

Start pos point, pos point of the first binlog file

Start reading the binlog at position N. Applies to the

First binlog passed on the command line.

-- stop-datetime=name

Termination time point

Stop reading the binlog at first event having a datetime

Equal or posterior to the argument; the argument must be

A date and time in the local time zone, in any format

Accepted by the MySQL server for DATETIME and TIMESTAMP

Types, for example: 2004-12-25 11:25:56 (you should

Probably use quotes for your shell to set it properly).

-- stop-never is used for remote backup of binlog

Wait for more data from the server instead of stopping at

The end of the last log. Implicitly sets-to-last-log

But instead of stopping at the end of the last log it

Continues to wait till the server disconnects.

-- stop-never-slave-server-id=#

The slave server_id used for-read-from-remote-server

-- stop-never.

-- stop-position=# the last specified file pos point

Stop reading the binlog at position N. Applies to the

Last binlog passed on the command line.

-t,-- to-last-log

Originating from a remote backup or downloading the binlog of the remote server locally, this parameter represents the destination binlog file, such as mysql-binlog.00234

Requires-R. Will not stop at the end of the requested

Binlog but rather continue printing until the end of the

Last binlog of the MySQL server. If you send the output

To the same MySQL server, that may lead to an endless

Loop.

-u,-- user=name Connect to the remote server as username.

-v,-- verbose Reconstruct pseudo-SQL statements out of row events. -v

-v adds comments on column data types.

V,-- version Print version and exit.

-- open-files-limit=#

Used to reserve file descriptors for use by this program.

-c,-- verify-binlog-checksum

Verify checksum binlog events.

-- binlog-row-event-max-size=#

The maximum size of a row-based binary log event in

Bytes. Rows will be grouped into events smaller than this

Size if possible. This value must be a multiple of 256.

-- skip-gtids

Do not print Global Transaction Identifier information

(SET GTID_NEXT=... Etc).

-- include-gtids=name

Print events whose Global Transaction Identifiers were

Provided.

-- exclude-gtids=name

Print all events but those whose Global Transaction

Identifiers were provided.

Variables (--variable-name=value)

And boolean options {FALSE | TRUE} Value (after reading options)

Base64-output (No default value)

Bind-address (No default value)

Character-sets-dir (No default value)

Database (No default value)

Debug-check FALSE

Debug-info FALSE

Default-auth (No default value)

Disable-log-bin FALSE

Force-if-open TRUE

Force-read FALSE

Hexdump FALSE

Host (No default value)

Local-load (No default value)

Offset 0

Plugin-dir (No default value)

Port 0

Read-from-remote-server FALSE

Read-from-remote-master (No default value)

Raw FALSE

Result-file (No default value)

Secure-auth TRUE

Server-id 0

Server-id-bits 32

Set-charset (No default value)

Short-form FALSE

Socket / tmp/mysql.sock

Start-datetime (No default value)

Start-position 4

Stop-datetime (No default value)

Stop-never FALSE

Stop-never-slave-server-id-1

Stop-position 18446744073709551615

To-last-log FALSE

User (No default value)

Open-files-limit 64

Verify-binlog-checksum FALSE

Binlog-row-event-max-size 4294967040

Skip-gtids FALSE

Include-gtids (No default value)

Exclude-gtids (No default value)

Example:

1. Read the database test from the remote server at the start time of 2017-09-26 12 binlog 05purl 00'

Mysqlbinlog-uroot-p123456-h292.168.1.100-R-d test-- start-datetime='2017-09-26 12 test 05test 00'-- base64-output=decode-rows-vv mysql-binlog.000004 mysql-binlog.000004 | more

2. Synchronize binlog from a remote server

Mysqlbinlog-uroot-p123456-h292.168.1.100-R-raw-stop-never-r mysql mysql-binlog.000001

If executed on the mysql server, remove-uroot-p123456-h292.168.1.100-R

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report