The server's binary log consists of files containing “events” that describe modifications to database contents. The server writes these files in binary format. 服务器的二进制日志由包含描述数据库内容修改的“事件”的文件组成。服务器以二进制格式写入这些文件。To display their contents in text format, use the mysqlbinlog utility. 要以文本格式显示其内容,请使用mysqlbinlog实用程序。You can also use mysqlbinlog to display the contents of relay log files written by a replica server in a replication setup because relay logs have the same format as binary logs. 您还可以使用mysqlbinlog显示复制设置中副本服务器写入的中继日志文件的内容,因为中继日志的格式与二进制日志相同。The binary log and relay log are discussed further in Section 5.4.4, “The Binary Log”, and Section 17.2.4, “Relay Log and Replication Metadata Repositories”.二进制日志和中继日志将在第5.4.4节,“二进制日志”和第17.2.4节,“中继日志和复制元数据存储库”中进一步讨论。
Invoke mysqlbinlog like this:像这样调用mysqlbinlog:
mysqlbinlog [options
]log_file
...
For example, to display the contents of the binary log file named 例如,要显示名为binlog.000003
, use this command:binlog.000003
的二进制日志文件的内容,请使用以下命令:
mysqlbinlog binlog.0000003
The output includes events contained in 输出包括binlog.000003
. For statement-based logging, event information includes the SQL statement, the ID of the server on which it was executed, the timestamp when the statement was executed, how much time it took, and so forth. binlog.000003
中包含的事件。对于基于语句的日志记录,事件信息包括SQL语句、执行它的服务器的ID、执行语句的时间戳、花费的时间等等。For row-based logging, the event indicates a row change rather than an SQL statement. 对于基于行的日志记录,事件表示行更改,而不是SQL语句。See Section 17.2.1, “Replication Formats”, for information about logging modes.有关日志记录模式的信息,请参阅第17.2.1节,“复制格式”。
Events are preceded by header comments that provide additional information. For example:事件前面有提供附加信息的标题注释。例如:
# at 141 #100309 9:28:36 server id 123 end_log_pos 245 Query thread_id=3350 exec_time=11 error_code=0
In the first line, the number following 在第一行中,在at
indicates the file offset, or starting position, of the event in the binary log file.at
后面的数字表示二进制日志文件中事件的文件偏移量或起始位置。
The second line starts with a date and time indicating when the statement started on the server where the event originated. For replication, this timestamp is propagated to replica servers. 第二行以日期和时间开头,指示语句在事件发生的服务器上何时开始。对于复制,此时间戳会传播到副本服务器。server id
is the server_id
value of the server where the event originated. server id
是事件发生的服务器的server_id
值。end_log_pos
indicates where the next event starts (that is, it is the end position of the current event + 1). end_log_pos
表示下一个事件开始的位置(即当前事件+1的结束位置)。thread_id
indicates which thread executed the event. exec_time
is the time spent executing the event, on a replication source server. thread_id
表示哪个线程执行了该事件。exec_time
是在复制源服务器上执行事件所花费的时间。On a replica, it is the difference of the end execution time on the replica minus the beginning execution time on the source. 在副本上,它是副本上的结束执行时间减去源上的开始执行时间的差值。The difference serves as an indicator of how much replication lags behind the source. 这种差异可以作为复制落后于源的程度的指标。error_code
indicates the result from executing the event. Zero means that no error occurred.error_code
表示执行事件的结果。零表示没有发生错误。
When using event groups, the file offsets of events may be grouped together and the comments of events may be grouped together. Do not mistake these grouped events for blank file offsets.当使用事件组时,事件的文件偏移量可以分组在一起,事件的注释可以分组在一起来。不要将这些分组事件误认为是空白文件偏移。
The output from mysqlbinlog can be re-executed (for example, by using it as input to mysql) to redo the statements in the log. mysqlbinlog的输出可以重新执行(例如,将其用作mysql的输入),以重做日志中的语句。This is useful for recovery operations after an unexpected server exit. 这对于服务器意外退出后的恢复操作非常有用。For other usage examples, see the discussion later in this section and in Section 7.5, “Point-in-Time (Incremental) Recovery”. 有关其他使用示例,请参阅本节后面的讨论和第7.5节,“时间点(增量)恢复”。To execute the internal-use 要执行mysqlbinlog使用的内部BINLOG
statements used by mysqlbinlog, the user requires the BINLOG_ADMIN
privilege (or the deprecated SUPER
privilege), or the REPLICATION_APPLIER
privilege plus the appropriate privileges to execute each log event.USE BINLOG
语句,用户需要BINLOG_ADMIN
权限(或已弃用的SUPER
权限),或REPLICATION_APPLIER
权限加上适当的权限来执行每个日志事件。
You can use mysqlbinlog to read binary log files directly and apply them to the local MySQL server. 您可以使用mysqlbinlog直接读取二进制日志文件并将其应用于本地MySQL服务器。You can also read binary logs from a remote server by using the 您还可以使用--read-from-remote-server
option. --read-from-remote-server
选项从远程服务器读取二进制日志。To read remote binary logs, the connection parameter options can be given to indicate how to connect to the server. 要读取远程二进制日志,可以提供连接参数选项来指示如何连接到服务器。These options are --host
, --password
, --port
, --protocol
, --socket
, and --user
.
When binary log files have been encrypted, which can be done from MySQL 8.0.14 onwards, mysqlbinlog cannot read them directly, but can read them from the server using the 当二进制日志文件被加密时(可以从MySQL 8.0.14开始),mysqlbinlog不能直接读取它们,但可以使用--read-from-remote-server
option. --read-from-remote-server
选项从服务器读取它们。Binary log files are encrypted when the server's 当服务器的binlog_encryption
system variable is set to ON
. binlog_encryption
系统变量设置为ON时,二进制日志文件会被加密。The SHOW BINARY LOGS
statement shows whether a particular binary log file is encrypted or unencrypted. SHOW BINARY LOGS
语句显示特定二进制日志文件是加密的还是未加密的。Encrypted and unencrypted binary log files can also be distinguished using the magic number at the start of the file header for encrypted log files (加密和未加密的二进制日志文件也可以使用加密日志文件文件头开头的幻数(0xFD62696E
), which differs from that used for unencrypted log files (0xFE62696E
). 0xFD62696E
)来区分,这与用于未加密日志文件的幻数不同(0xFE62696E
)。Note that from MySQL 8.0.14, mysqlbinlog returns a suitable error if you attempt to read an encrypted binary log file directly, but older versions of mysqlbinlog do not recognise the file as a binary log file at all. 请注意,从MySQL 8.0.14开始,如果您尝试直接读取加密的二进制日志文件,mysqlbinlog会返回一个合适的错误,但旧版本的mysqlbinlog根本无法将该文件识别为二进制日志文件。For more information on binary log encryption, see Section 17.3.2, “Encrypting Binary Log Files and Relay Log Files”.有关二进制日志加密的更多信息,请参阅第17.3.2节,“加密二进制日志文件和中继日志文件”。
When binary log transaction payloads have been compressed, which can be done from MySQL 8.0.20 onwards, mysqlbinlog versions from that release on automatically decompress and decode the transaction payloads, and print them as they would uncompressed events. 当二进制日志事务有效负载被压缩时(可以从MySQL 8.0.20开始执行),该版本的mysqlbinlog版本会自动解压缩和解码事务有效负载,并像解压缩事件一样打印它们。Older versions of mysqlbinlog cannot read compressed transaction payloads. 旧版本的mysqlbinlog无法读取压缩的事务有效负载。When the server's 当服务器的binlog_transaction_compression系统变量设置为ON时,事务有效负载被压缩,然后作为单个事件(binlog_transaction_compression
system variable is set to ON
, transaction payloads are compressed and then written to the server's binary log file as a single event (a Transaction_payload_event
). transaction_payload_event
)写入服务器的二进制日志文件。With the 使用--verbose
option, mysqlbinlog adds comments stating the compression algorithm used, the compressed payload size that was originally received, and the resulting payload size after decompression.--verbose
选项,mysqlbinlog会添加注释,说明使用的压缩算法、最初收到的压缩有效载荷大小以及解压缩后的有效载荷大小。
The end position (mysqlbinlog为作为压缩事务有效负载一部分的单个事件声明的结束位置(end_log_pos
) that mysqlbinlog states for an individual event that was part of a compressed transaction payload is the same as the end position of the original compressed payload. end_log_pos
)与原始压缩有效负载的结束位置相同。Multiple decompressed events can therefore have the same end position.因此,多个解压缩事件可以具有相同的结束位置。
mysqlbinlog's own connection compression does less if transaction payloads are already compressed, but still operates on uncompressed transactions and headers.如果事务有效负载已经压缩,mysqlbinlog自己的连接压缩会做得更少,但仍然对未压缩的事务和标头进行操作。
For more information on binary log transaction compression, see Section 5.4.4.5, “Binary Log Transaction Compression”.有关二进制日志事务压缩的更多信息,请参阅第5.4.4.5节,“二进制日志事务编码”。
When running mysqlbinlog against a large binary log, be careful that the filesystem has enough space for the resulting files. 当对大型二进制日志运行mysqlbinlog时,请注意文件系统有足够的空间容纳生成的文件。To configure the directory that mysqlbinlog uses for temporary files, use the 要配置mysqlbinlog用于临时文件的目录,请使用TMPDIR
environment variable.TMPDIR
环境变量。
mysqlbinlog sets the value of mysqlbinlog在执行任何SQL语句之前将pseudo_slave_mode
to true before executing any SQL statements. pseudo_slave_mode
的值设置为true
。This system variable affects the handling of XA transactions, the 此系统变量影响XA事务的处理、original_commit_timestamp
replication delay timestamp and the original_server_version
system variable, and unsupported SQL modes.original_commit_timestamp
复制延迟时间戳和original_server_version
系统变量,以及不支持的SQL模式。
mysqlbinlog supports the following options, which can be specified on the command line or in the mysqlbinlog支持以下选项,可以在命令行或选项文件的[mysqlbinlog]
and [client]
groups of an option file. [mysqlbinlog]
和[client]
组中指定。For information about option files used by MySQL programs, see Section 4.2.2.2, “Using Option Files”.有关MySQL程序使用的选项文件的信息,请参阅第4.2.2.2节,“使用选项文件”。
Table 4.22 mysqlbinlog Options选项
--base64-output | |||
---|---|---|---|
--bind-address | |||
--binlog-row-event-max-size | |||
--character-sets-dir | |||
--compress | 8.0.17 | 8.0.18 | |
--compression-algorithms | 8.0.18 | ||
--connection-server-id | |||
--database | |||
--debug | |||
--debug-check | |||
--debug-info | |||
--default-auth | |||
--defaults-extra-file | |||
--defaults-file | |||
--defaults-group-suffix | |||
--disable-log-bin | |||
--exclude-gtids | |||
--force-if-open | |||
--force-read | |||
--get-server-public-key | |||
--help | |||
--hexdump | |||
--host | |||
--idempotent | |||
--include-gtids | |||
--local-load | |||
--login-path | .mylogin.cnf 读取登录路径选项 | ||
--no-defaults | |||
--offset | |||
--password | |||
--plugin-dir | |||
--port | |||
--print-defaults | |||
--print-table-metadata | |||
--protocol | |||
--raw | |||
--read-from-remote-master | |||
--read-from-remote-server | |||
--require-row-format | 8.0.19 | ||
--result-file | |||
--rewrite-db | |||
--server-id | |||
--server-id-bits | |||
--server-public-key-path | |||
--set-charset | |||
--shared-memory-base-name | |||
--short-form | |||
--skip-gtids | |||
--socket | |||
--ssl-ca | |||
--ssl-capath | |||
--ssl-cert | |||
--ssl-cipher | |||
--ssl-crl | |||
--ssl-crlpath | |||
--ssl-fips-mode | |||
--ssl-key | |||
--ssl-mode | |||
--start-datetime | |||
--start-position | |||
--stop-datetime | |||
--stop-never | |||
--stop-never-slave-server-id | |||
--stop-position | |||
--tls-ciphersuites | 8.0.16 | ||
--tls-version | |||
--to-last-log | |||
--user | |||
--verbose | |||
--verify-binlog-checksum | |||
--version | |||
--zstd-compression-level | 8.0.18 |
--help
, -?
Display a help message and exit.显示帮助消息并退出。
This option determines when events should be displayed encoded as base-64 strings using 此选项确定何时应使用BINLOG
statements. BINLOG
语句将事件编码为base-64字符串显示。The option has these permissible values (not case-sensitive):该选项具有以下允许值(不区分大小写):
AUTO
("automatic") or UNSPEC
("unspecified") displays BINLOG
statements automatically when necessary (that is, for format description events and row events). If no --base64-output
option is given, the effect is the same as --base64-output=AUTO
.AUTO
(“自动”)或UNSPEC
(“未指定”)在必要时自动显示BINLOG
语句(即用于格式描述事件和行事件)。如果没有给出--base64
输出选项,则效果与--base64-output=AUTO
相同。
Automatic 如果您打算使用mysqlbinlog的输出重新执行二进制日志文件内容,则自动BINLOG
display is the only safe behavior if you intend to use the output of mysqlbinlog to re-execute binary log file contents. BINLOG
显示是唯一安全的行为。The other option values are intended only for debugging or testing purposes because they may produce output that does not include all events in executable form.其他选项值仅用于调试或测试目的,因为它们可能会产生不包括可执行形式的所有事件的输出。
NEVER
causes BINLOG
statements not to be displayed. mysqlbinlog exits with an error if a row event is found that must be displayed using BINLOG
.NEVER
导致BINLOG
语句不显示。如果发现必须使用BINLOG
显示的行事件,mysqlbinlog将退出并返回错误。
DECODE-ROWS
specifies to mysqlbinlog that you intend for row events to be decoded and displayed as commented SQL statements by also specifying the --verbose
option. DECODE-ROWS
通过指定--verbose
选项,向mysqlbinlog指定您打算将行事件解码并显示为带注释的SQL语句。Like 与NEVER
, DECODE-ROWS
suppresses display of BINLOG
statements, but unlike NEVER
, it does not exit with an error if a row event is found.NEVER
一样,DECODE-ROWS
会抑制BINLOG
语句的显示,但与NEVER
不同的是,如果发现行事件,它不会以错误退出。
For examples that show the effect of 有关--base64-output
and --verbose
on row event output, see Section 4.6.9.2, “mysqlbinlog Row Event Display”.--base64-output
和--verbose
对行事件输出的影响的示例,请参阅第4.6.9.2节,“mysqlbinlog行事件显示”。
On a computer having multiple network interfaces, use this option to select which interface to use for connecting to the MySQL server.在具有多个网络接口的计算机上,使用此选项选择用于连接MySQL服务器的接口。
Command-Line Format | --binlog-row-event-max-size=# |
---|---|
Type | Numeric |
Default Value | 4294967040 |
Minimum Value | 256 |
Maximum Value | 18446744073709547520 |
Specify the maximum size of a row-based binary log event, in bytes. Rows are grouped into events smaller than this size if possible. The value should be a multiple of 256. The default is 4GB.指定基于行的二进制日志事件的最大大小(以字节为单位)。如果可能的话,行被分组为小于此大小的事件。该值应该是256的倍数。默认值为4GB。
The directory where character sets are installed. See Section 10.15, “Character Set Configuration”.安装字符集的目录。参阅第10.15节,“字符集配置”。
Compress all information sent between the client and the server if possible. See Section 4.2.8, “Connection Compression Control”.如果可能的话,压缩客户端和服务器之间发送的所有信息。参阅第4.2.8节,“连接压缩控制”。
This option was added in MySQL 8.0.17. As of MySQL 8.0.18 it is deprecated. Expect it to be removed in a future version of MySQL. See Configuring Legacy Connection Compression.此选项是在MySQL 8.0.17中添加的。从MySQL 8.0.18开始,它已被弃用。预计它将在MySQL的未来版本中被删除。请参阅配置传统连接压缩。
--compression-algorithms=
value
The permitted compression algorithms for connections to the server. The available algorithms are the same as for the 允许用于连接到服务器的压缩算法。可用的算法与protocol_compression_algorithms
system variable. protocol_compression_algorithms
系统变量的算法相同。The default value is 默认值为uncompressed
.uncompressed
。
For more information, see Section 4.2.8, “Connection Compression Control”.有关更多信息,请参阅第4.2.8节,“连接压缩控制”。
This option was added in MySQL 8.0.18.此选项是在MySQL 8.0.18中添加的。
--connection-server-id=
server_id
--connection-server-id
specifies the server ID that mysqlbinlog reports when it connects to the server. --connection-server-id
指定mysqlbinlog在连接到服务器时报告的服务器ID。It can be used to avoid a conflict with the ID of a replica server or another mysqlbinlog process.它可用于避免与副本服务器或另一个mysqlbinlog进程的ID冲突。
If the 如果指定了--read-from-remote-server
option is specified, mysqlbinlog reports a server ID of 0, which tells the server to disconnect after sending the last log file (nonblocking behavior). --read-from-remote-server
选项,则mysqlbinlog报告服务器ID为0,这告诉服务器在发送最后一个日志文件后断开连接(非阻塞行为)。If the 如果还指定了--stop-never
option is also specified to maintain the connection to the server, mysqlbinlog reports a server ID of 1 by default instead of 0, and --connection-server-id
can be used to replace that server ID if required. --stop-never
选项来保持与服务器的连接,mysqlbinlog默认报告服务器ID为1,而不是0,如果需要,可以使用--connection-server-id
替换该服务器ID。See Section 4.6.9.4, “Specifying the mysqlbinlog Server ID”.请参阅第4.6.9.4节,“指定mysqlbinlog服务器ID”。
--database=
, db_name
-d
db_name
This option causes mysqlbinlog to output entries from the binary log (local log only) that occur while 此选项会导致mysqlbinlog输出二进制日志(仅限本地日志)中的条目,这些条目是在db_name
is been selected as the default database by USE
.USE
将db_name
选为默认数据库时出现的。
The mysqlbinlog的--database
option for mysqlbinlog is similar to the --binlog-do-db
option for mysqld, but can be used to specify only one database. --database
选项类似于mysqld的--binlog-do-db
选项,但只能用于指定一个数据库。If 如果多次给出--database
is given multiple times, only the last instance is used.--database
,则只使用最后一个实例。
The effects of this option depend on whether the statement-based or row-based logging format is in use, in the same way that the effects of 此选项的效果取决于使用的是基于语句还是基于行的日志记录格式,就像--binlog-do-db
depend on whether statement-based or row-based logging is in use.--binlog-do-db
的效果取决于使用的是面向语句还是基于行将日志记录一样。
Statement-based logging. The --database
option works as follows:--database
选项的工作原理如下:
While 虽然db_name
is the default database, statements are output whether they modify tables in db_name
or a different database.db_name
是默认数据库,但无论语句是修改db_name
中的表还是修改其他数据库,都会输出语句。
Unless 除非选择db_name
is selected as the default database, statements are not output, even if they modify tables in db_name
.db_name
作为默认数据库,否则不会输出语句,即使它们修改了db_name
中的表。
There is an exception for CREATE DATABASE
, ALTER DATABASE
, and DROP DATABASE
. CREATE DATABASE
、ALTER DATABASE
和DROP DATABASE
存在异常。The database being created, altered, or dropped is considered to be the default database when determining whether to output the statement.在确定是否输出语句时,正在创建、更改或删除的数据库被视为默认数据库。
Suppose that the binary log was created by executing these statements using statement-based-logging:假设二进制日志是通过使用基于语句的日志记录执行以下语句创建的:
INSERT INTO test.t1 (i) VALUES(100); INSERT INTO db2.t2 (j) VALUES(200); USE test; INSERT INTO test.t1 (i) VALUES(101); INSERT INTO t1 (i) VALUES(102); INSERT INTO db2.t2 (j) VALUES(201); USE db2; INSERT INTO test.t1 (i) VALUES(103); INSERT INTO db2.t2 (j) VALUES(202); INSERT INTO t2 (j) VALUES(203);
mysqlbinlog --database=test does not output the first two INSERT
statements because there is no default database. mysqlbinlog --database=test
不输出前两个INSERT
语句,因为没有默认数据库。It outputs the three 它在INSERT
statements following USE test
, but not the three INSERT
statements following USE db2
.USE
测试后输出三个INSERT
语句,但在USE db2
后不输出三个INSERT语句。
mysqlbinlog --database=db2 does not output the first two INSERT
statements because there is no default database. mysqlbinlog --database=db2
不输出前两个INSERT
语句,因为没有默认数据库。It does not output the three 它不会在INSERT
statements following USE test
, but does output the three INSERT
statements following USE db2
.USE
测试后输出三个INSERT
语句,但会在USE db2
后输出三条INSERT
语句。
Row-based logging. mysqlbinlog outputs only entries that change tables belonging to mysqlbinlog只输出更改属于db_name
. db_name
的表的条目。The default database has no effect on this. Suppose that the binary log just described was created using row-based logging rather than statement-based logging. 默认数据库对此没有影响。假设刚才描述的二进制日志是使用基于行的日志而不是基于语句的日志创建的。mysqlbinlog --database=test outputs only those entries that modify t1
in the test database, regardless of whether USE
was issued or what the default database is.mysqlbinlog --database=test
只输出那些在测试数据库中修改t1
的条目,而不管是否发出USE
或默认数据库是什么。
If a server is running with 如果服务器在binlog_format
set to MIXED
and you want it to be possible to use mysqlbinlog with the --database
option, you must ensure that tables that are modified are in the database selected by USE
. binlog_format
设置为MIXED的情况下运行,并且您希望可以使用mysqlbinlog和--database
选项,则必须确保修改的表位于USE
选择的数据库中。(In particular, no cross-database updates should be used.)(特别是,不应使用跨数据库更新。)
When used together with the 当与--rewrite-db
option, the --rewrite-db
option is applied first; then the --database
option is applied, using the rewritten database name. --rewrite-db
选项一起使用时,--rewrite-db
选项将首先应用;然后使用重写的数据库名称应用--database
选项。The order in which the options are provided makes no difference in this regard.在这方面,提供选项的顺序没有区别。
--debug[=
, debug_options
]-# [
debug_options
]
Write a debugging log. A typical 编写调试日志。典型的debug_options
string is d:t:o,
. The default is file_name
d:t:o,/tmp/mysqlbinlog.trace
.debug_options
字符串是d:t:o,file_name
。默认值为d:t:o,/tmp/mysqlbinlog.trace
。
This option is available only if MySQL was built using 仅当MySQL使用WITH_DEBUG
. MySQL release binaries provided by Oracle are not built using this option.WITH_DEBUG
构建时,此选项才可用。Oracle提供的MySQL发布二进制文件不是使用此选项构建的。
Print some debugging information when the program exits.程序退出时打印一些调试信息。
This option is available only if MySQL was built using 仅当MySQL使用WITH_DEBUG
. MySQL release binaries provided by Oracle are not built using this option.WITH_DEBUG
构建时,此选项才可用。Oracle提供的MySQL发布二进制文件不是使用此选项构建的。
Print debugging information and memory and CPU usage statistics when the program exits.程序退出时打印调试信息以及内存和CPU使用统计数据。
This option is available only if MySQL was built using 仅当MySQL使用WITH_DEBUG
. MySQL release binaries provided by Oracle are not built using this option.WITH_DEBUG
构建时,此选项才可用。Oracle提供的MySQL发布二进制文件不是使用此选项构建的。
A hint about which client-side authentication plugin to use. 关于使用哪个客户端身份验证插件的提示。See Section 6.2.17, “Pluggable Authentication”.请参阅第6.2.17节,“可插拔身份验证”。
--defaults-extra-file=
file_name
Read this option file after the global option file but (on Unix) before the user option file. If the file does not exist or is otherwise inaccessible, an error occurs. If 在全局选项文件之后读取此选项文件,但(在Unix上)在用户选项文件之前读取。如果文件不存在或无法访问,则会发生错误。如果file_name
is not an absolute path name, it is interpreted relative to the current directory.file_name
不是绝对路径名,则会相对于当前目录进行解释。
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.有关此选项和其他选项文件选项的更多信息,请参阅第4.2.2.3节,“影响选项文件处理的命令行选项”。
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If 仅使用给定的选项文件。如果文件不存在或无法访问,则会发生错误。如果file_name
is not an absolute path name, it is interpreted relative to the current directory.file_name
不是绝对路径名,则会相对于当前目录进行解释。
Exception: Even with 异常:即使使用--defaults-file
, client programs read .mylogin.cnf
.--defaults-file
,客户端程序也会读取.mylogin.cnf
。
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.有关此选项和其他选项文件选项的更多信息,请参阅第4.2.2.3节,“影响选项文件处理的命令行选项”。
Read not only the usual option groups, but also groups with the usual names and a suffix of 不仅要读取常用的选项组,还要读取具有常用名称和后缀str
. str
的组。For example, mysqlbinlog normally reads the 例如,mysqlbinlog通常读取[client]
and [mysqlbinlog]
groups. [client]
和[mysqlbinlog]
组。If this option is given as 如果将此选项设置为--defaults-group-suffix=_other
, mysqlbinlog also reads the [client_other]
and [mysqlbinlog_other]
groups.--defaults-group-suffix=_other
,mysqlbinlog还会读取[client_other]
和[mysqlbinlog_other]
组。
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.有关此选项和其他选项文件选项的更多信息,请参阅第4.2.2.3节,“影响选项文件处理的命令行选项”。
Disable binary logging. This is useful for avoiding an endless loop if you use the 禁用二进制日志记录。如果您使用--to-last-log
option and are sending the output to the same MySQL server. --to-last-log
选项并将输出发送到同一MySQL服务器,这对于避免无休止的循环非常有用。This option also is useful when restoring after an unexpected exit to avoid duplication of the statements you have logged.在意外退出后进行还原时,此选项也很有用,以避免重复您记录的语句。
This option causes mysqlbinlog to include a 此选项导致mysqlbinlog在其输出中包含SET sql_log_bin = 0
statement in its output to disable binary logging of the remaining output. SET sql_log_bin=0
语句,以禁用剩余输出的二进制日志记录。Manipulating the session value of the 操纵sql_log_bin
system variable is a restricted operation, so this option requires that you have privileges sufficient to set restricted session variables. sql_log_bin
系统变量的会话值是一种受限操作,因此此选项要求您具有足够的权限来设置受限的会话变量。See Section 5.1.9.1, “System Variable Privileges”.请参阅第5.1.9.1节,“系统变量权限”。
Do not display any of the groups listed in the 不要显示gtid_set
.gtid_set
中列出的任何组。
--force-if-open
, -F
Read binary log files even if they are open or were not closed properly.读取二进制日志文件,即使它们已打开或未正确关闭。
--force-read
, -f
With this option, if mysqlbinlog reads a binary log event that it does not recognize, it prints a warning, ignores the event, and continues. 使用此选项,如果mysqlbinlog读取到它无法识别的二进制日志事件,它会打印一条警告,忽略该事件并继续。Without this option, mysqlbinlog stops if it reads such an event.如果没有此选项,mysqlbinlog在读取到此类事件时将停止。
Request from the server the public key required for RSA key pair-based password exchange. 从服务器请求基于RSA密钥对的密码交换所需的公钥。This option applies to clients that authenticate with the 此选项适用于使用caching_sha2_password
authentication plugin. caching_sha2_password
身份验证插件进行身份验证的客户端。For that plugin, the server does not send the public key unless requested. 对于该插件,除非请求,否则服务器不会发送公钥。This option is ignored for accounts that do not authenticate with that plugin. 对于不使用该插件进行身份验证的帐户,此选项将被忽略。It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.如果不使用基于RSA的密码交换,它也会被忽略,就像客户端使用安全连接连接到服务器的情况一样。
If 如果给定了--server-public-key-path=
is given and specifies a valid public key file, it takes precedence over file_name
--get-server-public-key
.--server-public-key-path=file_name
并指定了一个有效的公钥文件,则它优先于--get-server-public-key
。
For information about the 有关caching_sha2_password
plugin, see Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.caching_sha2_password
插件的信息,请参阅第6.4.1.2节,“缓存SHA-2可插拔身份验证”。
--hexdump
, -H
Display a hex dump of the log in comments, as described in Section 4.6.9.1, “mysqlbinlog Hex Dump Format”. The hex output can be helpful for replication debugging.显示登录注释的十六进制转储,如第4.6.9.1节,“mysqlbinlog十六进制转储格式”所述。十六进制输出有助于复制调试。
--host=
, host_name
-h
host_name
Get the binary log from the MySQL server on the given host.从给定主机上的MySQL服务器获取二进制日志。
Tell the MySQL Server to use idempotent mode while processing updates; this causes suppression of any duplicate-key or key-not-found errors that the server encounters in the current session while processing updates. 告诉MySQL服务器在处理更新时使用幂等模式;这会导致抑一致性务器在处理更新时在当前会话中遇到的任何重复密钥或未找到密钥的错误。This option may prove useful whenever it is desirable or necessary to replay one or more binary logs to a MySQL Server which may not contain all of the data to which the logs refer.当需要或有必要将一个或多个二进制日志重播到MySQL服务器时,此选项可能会很有用,MySQL服务器可能不包含日志引用的所有数据。
The scope of effect for this option includes the current mysqlbinlog client and session only.此选项的作用范围仅包括当前的mysqlbinlog客户端和会话。
Display only the groups listed in the 仅显示gtid_set
.gtid_set
中列出的组。
--local-load=
, dir_name
-l
dir_name
For data loading operations corresponding to 对于与LOAD DATA
statements, mysqlbinlog extracts the files from the binary log events, writes them as temporary files to the local file system, and writes LOAD DATA LOCAL
statements to cause the files to be loaded. LOAD DATA
语句对应的数据加载操作,mysqlbinlog从二进制日志事件中提取文件,将它们作为临时文件写入本地文件系统,并写入LOAD DATA LOCAL
语句以加载文件。By default, mysqlbinlog writes these temporary files to an operating system-specific directory. 默认情况下,mysqlbinlog会将这些临时文件写入操作系统特定的目录。The --local-load
option can be used to explicitly specify the directory where mysqlbinlog should prepare local temporary files.--local-load
选项可用于显式指定mysqlbinlog应在其中准备本地临时文件的目录。
Because other processes can write files to the default system-specific directory, it is advisable to specify the 因为其他进程可以将文件写入默认的系统特定目录,所以建议在mysqlbinlog中指定--local-load
option to mysqlbinlog to designate a different directory for data files, and then designate that same directory by specifying the --load-data-local-dir
option to mysql when processing the output from mysqlbinlog. For example:--local-load
选项,为数据文件指定一个不同的目录,然后在处理mysqlbinlog的输出时,通过在mysql中指定--load-data-local-dir
选项来指定同一个目录。例如:
mysqlbinlog --local-load=/my/local/data ... | mysql --load-data-local-dir=/my/local/data ...
These temporary files are not automatically removed by mysqlbinlog or any other MySQL program.这些临时文件不会被mysqlbinlog或任何其他MySQL程序自动删除。
Read options from the named login path in the 从.mylogin.cnf
login path file. .mylogin.cnf
登录路径文件中的指定登录路径读取选项。A “login path” is an option group containing options that specify which MySQL server to connect to and which account to authenticate as. “登录路径”是一个选项组,其中包含指定要连接到哪个MySQL服务器以及要作为哪个帐户进行身份验证的选项。To create or modify a login path file, use the mysql_config_editor utility. 要创建或修改登录路径文件,请使用mysql_config_editor实用程序。See Section 4.6.7, “mysql_config_editor — MySQL Configuration Utility”.请参阅第4.6.7节,“mysql_config编辑器--mysql配置实用程序”。
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.有关此选项和其他选项文件选项的更多信息,请参阅第4.2.2.3节,“影响选项文件处理的命令行选项”。
Do not read any option files. If program startup fails due to reading unknown options from an option file, 不要读取任何选项文件。如果程序启动因从选项文件中读取未知选项而失败,则使用--no-defaults
can be used to prevent them from being read.--no-defaults
来阻止读取它们。
The exception is that the 例外的是,.mylogin.cnf
file is read in all cases, if it exists. .mylogin.cnf
文件在所有情况下都会被读取(如果存在的话)。This permits passwords to be specified in a safer way than on the command line even when 这允许以比命令行更安全的方式指定密码,即使使用--no-defaults
is used. --no-defaults
。To create .mylogin.cnf
, use the mysql_config_editor utility. See Section 4.6.7, “mysql_config_editor — MySQL Configuration Utility”.请参阅第4.6.7节,“mysql_config编辑器--mysql配置实用程序”。
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.有关此选项和其他选项文件选项的更多信息,请参阅第4.2.2.3节,“影响选项文件处理的命令行选项”。
--offset=
, N
-o
N
Skip the first 跳过日志中的前N
entries in the log.N
个条目。
Specify the number of open file descriptors to reserve.指定要保留的打开文件描述符的数量。
--password[=
, password
]-p[
password
]
The password of the MySQL account used for connecting to the server. The password value is optional. 用于连接到服务器的MySQL帐户的密码。密码值是可选的。If not given, mysqlbinlog prompts for one. 如果没有给出,mysqlbinlog会提示输入一个。If given, there must be no space between 如果给定,则--password=
or -p
and the password following it. If no password option is specified, the default is to send no password.--password=
或-p
与其后面的密码之间不得有空格。如果未指定密码选项,则默认情况下不发送密码。
Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. See Section 6.1.2.1, “End-User Guidelines for Password Security”.在命令行上指定密码应被视为不安全。为了避免在命令行上输入密码,请使用选项文件。请参阅第6.1.2.1节,“密码安全最终用户指南”。
To explicitly specify that there is no password and that mysqlbinlog should not prompt for one, use the 要明确指定没有密码并且mysqlbinlog不应提示输入密码,请使用--skip-password
option.--skip-password
选项。
The directory in which to look for plugins. 查找插件的目录。Specify this option if the 如果使用--default-auth
option is used to specify an authentication plugin but mysqlbinlog does not find it. --default-auth
选项指定身份验证插件,但mysqlbinlog找不到它,请指定此选项。See Section 6.2.17, “Pluggable Authentication”.请参阅第6.2.17节,“可插拔身份验证”。
--port=
, port_num
-P
port_num
The TCP/IP port number to use for connecting to a remote server.用于连接到远程服务器的TCP/IP端口号。
Print the program name and all options that it gets from option files.打印程序名称及其从选项文件中获取的所有选项。
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.有关此选项和其他选项文件选项的更多信息,请参阅第4.2.2.3节,“影响选项文件处理的命令行选项”。
Print table related metadata from the binary log. 从二进制日志中打印与表相关的元数据。Configure the amount of table related metadata binary logged using 使用binlog-row-metadata
.binlog-row-metadata
配置二进制记录的表相关元数据的数量。
--protocol={TCP|SOCKET|PIPE|MEMORY}
The transport protocol to use for connecting to the server. It is useful when the other connection parameters normally result in use of a protocol other than the one you want. 用于连接到服务器的传输协议。当其他连接参数通常导致使用与您想要的协议不同的协议时,它很有用。For details on the permissible values, see Section 4.2.7, “Connection Transport Protocols”.有关允许值的详细信息,请参阅第4.2.7节,“连接传输协议”。
By default, mysqlbinlog reads binary log files and writes events in text format. 默认情况下,mysqlbinlog读取二进制日志文件并以文本格式写入事件。The --raw
option tells mysqlbinlog to write them in their original binary format. --raw
选项告诉mysqlbinlog以原始二进制格式编写它们。Its use requires that 它的使用要求也使用--read-from-remote-server
also be used because the files are requested from a server. --read-from-remote-server
,因为文件是从服务器请求的。mysqlbinlog writes one output file for each file read from the server. mysqlbinlog为从服务器读取的每个文件写入一个输出文件。The --raw
option can be used to make a backup of a server's binary log. --raw
选项可用于备份服务器的二进制日志。With the 使用--stop-never
option, the backup is “live” because mysqlbinlog stays connected to the server. --stop-never
选项,备份是“实时”的,因为mysqlbinlog保持与服务器的连接。By default, output files are written in the current directory with the same names as the original log files. 默认情况下,输出文件以与原始日志文件相同的名称写入当前目录。Output file names can be modified using the 可以使用--result-file
option. --result-file
选项修改输出文件名。For more information, see Section 4.6.9.3, “Using mysqlbinlog to Back Up Binary Log Files”.有关更多信息,请参阅第4.6.9.3节,“使用mysqlbinlog备份二进制日志文件”。
--read-from-remote-master=
type
Read binary logs from a MySQL server with the 通过将选项值分别设置为COM_BINLOG_DUMP
or COM_BINLOG_DUMP_GTID
commands by setting the option value to either BINLOG-DUMP-NON-GTIDS
or BINLOG-DUMP-GTIDS
, respectively. BINLOG-DUMP-NON-GTIDS
或BINLOG-DUPP-GTIDS
,使用COM_BINLOG_DUMP
或COM_BINLOG_DUMP_GTID
命令从MySQL服务器读取二进制日志。If 如果--read-from-remote-master=BINLOG-DUMP-GTIDS
is combined with --exclude-gtids
, transactions can be filtered out on the source, avoiding unnecessary network traffic.--read-from-remote-master=BINLOG-DUMP-GTIDS
与--exclude-gtids
结合使用,则可以在源上筛选掉事务,避免不必要的网络流量。
The connection parameter options are used with this option or the 连接参数选项与此选项--read-from-remote-server
option. --read-from-remote-server
选项一起使用。These options are 这些选项是--host
, --password
, --port
, --protocol
, --socket
, and --user
. --host
、--password
、--port
、--protocol
、--socket
和--user
。If neither of the remote options is specified, the connection parameter options are ignored.如果未指定任何远程选项,则忽略连接参数选项。
The 使用此选项需要REPLICATION SLAVE
privilege is required to use this option.REPLICATION SLAVE
权限。
Read the binary log from a MySQL server rather than reading a local log file. This option requires that the remote server be running. It works only for binary log files on the remote server, not relay log files.从MySQL服务器读取二进制日志,而不是读取本地日志文件。此选项要求远程服务器正在运行。它仅适用于远程服务器上的二进制日志文件,不适用于中继日志文件。
The connection parameter options are used with this option or the 连接参数选项与此选项或--read-from-remote-master
option. --read-from-remote-master
选项一起使用。These options are 这些选项是--host
, --password
, --port
, --protocol
, --socket
, and --user
. --host
、--password
、--port
、--protocol
、--socket
和--user
。If neither of the remote options is specified, the connection parameter options are ignored.如果未指定任何远程选项,则忽略连接参数选项。
The 使用此选项需要REPLICATION SLAVE
privilege is required to use this option.REPLICATION SLAVE
权限。
This option is like 此选项类似于--read-from-remote-master=BINLOG-DUMP-NON-GTIDS
.--read-from-remote-master=BINLOG-DUMP-NON-GTIDS
。
--result-file=
, name
-r
name
Without the 如果没有--raw
option, this option indicates the file to which mysqlbinlog writes text output. --raw
选项,此选项指示mysqlbinlog将文本输出写入的文件。With 使用--raw
, mysqlbinlog writes one binary output file for each log file transferred from the server, writing them by default in the current directory using the same names as the original log file. --raw
,mysqlbinlog会为从服务器传输的每个日志文件写入一个二进制输出文件,默认情况下会使用与原始日志文件相同的名称将其写入当前目录。In this case, the 在这种情况下,--result-file
option value is treated as a prefix that modifies output file names.--result-file
选项值被视为修改输出文件名的前缀。
Require row-based binary logging format for events. This option enforces row-based replication events for mysqlbinlog output. 事件需要基于行的二进制日志记录格式。此选项对mysqlbinlog输出强制执行基于行的复制事件。The stream of events produced with this option would be accepted by a replication channel that is secured using the 使用此选项生成的事件流将被复制通道接受,该复制通道使用REQUIRE_ROW_FORMAT
option of the CHANGE REPLICATION SOURCE TO
statement (from MySQL 8.0.23) or CHANGE MASTER TO
statement (before MySQL 8.0.23). binlog_format=ROW
must be set on the server where the binary log was written. CHANGE REPLICATION SOURCE TO
语句(来自MySQL 8.0.23)或CHANGE MASTER TO
语句(MySQL 8.0.22之前)的REQUIRE_ROW_FORMAT
选项进行保护。必须在写入二进制日志的服务器上设置binlog_format=ROW
。When you specify this option, mysqlbinlog stops with an error message if it encounters any events that are disallowed under the 当您指定此选项时,如果mysqlbinlog遇到任何在REQUIRE_ROW_FORMAT
restrictions, including LOAD DATA INFILE
instructions, creating or dropping temporary tables, INTVAR
, RAND
, or USER_VAR
events, and non-row-based events within a DML transaction. REQUIRE_ROW_FORMAT
限制下不允许的事件,包括LOAD DATA INFILE
指令、创建或删除临时表、INTVAR
、RAND
或USER_VAR
事件以及DML事务中的非基于行的事件,mysqlbinlog将停止并显示错误消息。mysqlbinlog also prints a mysqlbinlog还在其输出的开头打印SET @@session.require_row_format
statement at the start of its output to apply the restrictions when the output is executed, and does not print the SET @@session.pseudo_thread_id
statement.SET @@session.require_row_format
语句,以便在执行输出时应用限制,并且不打印SET @@session.pseudo_thread_id
语句。
This option was added in MySQL 8.0.19.此选项是在MySQL 8.0.19中添加的。
--rewrite-db='
from_name
->to_name
'
When reading from a row-based or statement-based log, rewrite all occurrences of 从基于行或基于语句的日志读取时,将所有出现的from_name
to to_name
. from_name
重写为to_name
。Rewriting is done on the rows, for row-based logs, as well as on the 对于基于行的日志,重写是在行上完成的,对于基于语句的日志,则重写是在USE
clauses, for statement-based logs.USE
子句上完成的。
Statements in which table names are qualified with database names are not rewritten to use the new name when using this option.使用此选项时,表名用数据库名限定的语句不会被重写以使用新名称。
The rewrite rule employed as a value for this option is a string having the form 用作此选项值的重写规则是一个格式为'
, as shown previously, and for this reason must be enclosed by quotation marks.from_name
->to_name
''from_name->to_name'
的字符串,如前所示,因此必须用引号括起来。
To employ multiple rewrite rules, specify the option multiple times, as shown here:要使用多个重写规则,请多次指定该选项,如下所示:
mysqlbinlog --rewrite-db='dbcurrent->dbold' --rewrite-db='dbtest->dbcurrent' \ binlog.00001 > /tmp/statements.sql
When used together with the 当与--database
option, the --rewrite-db
option is applied first; then --database
option is applied, using the rewritten database name. The order in which the options are provided makes no difference in this regard.--database
选项一起使用时,--rewrite-db
选项将首先应用;然后,使用重写的数据库名称应用--database
选项。在这方面,提供选项的顺序没有区别。
This means that, for example, if mysqlbinlog is started with 这意味着,例如,如果mysqlbinlog以--rewrite-db='mydb->yourdb' --database=yourdb
, then all updates to any tables in databases mydb
and yourdb
are included in the output. --rewrite-db='mydb->yourdb' --database=yourdb
开头,则数据库mydb
和yourdb
中任何表的所有更新都将包含在输出中。On the other hand, if it is started with 另一方面,如果它以--rewrite-db='mydb->yourdb' --database=mydb
, then mysqlbinlog outputs no statements at all: since all updates to mydb
are first rewritten as updates to yourdb
before applying the --database
option, there remain no updates that match --database=mydb
.--rewrite db='mydb->yourdb' --database=mydb
开头,则mysqlbinlog根本不输出任何语句:由于在应用--database
选项之前,mydb
的所有更新都首先被重写为yourdb
的更新,因此没有与--database=mydb
匹配的更新。
Display only those events created by the server having the given server ID.仅显示由具有给定服务器ID的服务器创建的事件。
Use only the first 仅使用N
bits of the server_id
to identify the server. server_id
的前N
位来标识服务器。If the binary log was written by a mysqld with server-id-bits set to less than 32 and user data stored in the most significant bit, running mysqlbinlog with 如果二进制日志是由mysqld写入的,服务器id位设置为小于32,用户数据存储在最高有效位,则运行mysqlbinlog,将--server-id-bits
set to 32 enables this data to be seen.--server-id-bits
设置成32,可以看到这些数据。
This option is supported only by the version of mysqlbinlog supplied with the NDB Cluster distribution, or built with NDB Cluster support.此选项仅由NDB Cluster发行版提供的mysqlbinlog版本支持,或由NDB群集支持构建。
--server-public-key-path=
file_name
The path name to a file in PEM format containing a client-side copy of the public key required by the server for RSA key pair-based password exchange. This option applies to clients that authenticate with the PEM格式文件的路径名,该文件包含服务器基于RSA密钥对进行密码交换所需的公钥客户端副本。此选项适用于使用sha256_password
or caching_sha2_password
authentication plugin. sha256_password
或caching_sha2_password
身份验证插件进行身份验证的客户端。This option is ignored for accounts that do not authenticate with one of those plugins. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.对于未使用这些插件之一进行身份验证的帐户,此选项将被忽略。如果不使用基于RSA的密码交换,它也会被忽略,就像客户端使用安全连接连接到服务器的情况一样。
If 如果给定了--server-public-key-path=
is given and specifies a valid public key file, it takes precedence over file_name
--get-server-public-key
.--server-public-key-path=file_name
并指定了一个有效的公钥文件,则它优先于--get-server-public-key
。
For 对于sha256_password
, this option applies only if MySQL was built using OpenSSL.sha256_password
,此选项仅适用于使用OpenSSL构建MySQL的情况。
For information about the 有关sha256_password
and caching_sha2_password
plugins, see Section 6.4.1.3, “SHA-256 Pluggable Authentication”, and Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.sha256_password
和caching_sha2_password
插件的信息,请参阅第6.4.1.3节,“SHA-256可插拔身份验证”和第6.4.1.2节,“缓存SHA-2可插拔身份认证”。
Add a 在输出中添加SET NAMES
statement to the output to specify the character set to be used for processing log files.charset_name
SET NAMES charset_name
语句,以指定用于处理日志文件的字符集。
--shared-memory-base-name=
name
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 在Windows上,用于使用共享内存连接到本地服务器的共享内存名称。默认值为MYSQL
. The shared-memory name is case-sensitive.MYSQL
。共享内存名称区分大小写。
This option applies only if the server was started with the 此选项仅适用于服务器启动时启用了shared_memory
system variable enabled to support shared-memory connections.shared_memory
系统变量以支持共享内存连接的情况。
--short-form
, -s
Display only the statements contained in the log, without any extra information or row-based events. This is for testing only, and should not be used in production systems. It is deprecated, and you should expect it to be removed in a future release.仅显示日志中包含的语句,不显示任何额外信息或基于行的事件。这仅用于测试,不应用于生产系统。它已被弃用,您应该期望在未来的版本中将其删除。
Do not display any GTIDs in the output. This is needed when writing to a dump file from one or more binary logs containing GTIDs, as shown in this example:输出中不显示任何GTID。当从一个或多个包含GTID的二进制日志写入转储文件时,需要这样做,如下例所示:
mysqlbinlog --skip-gtids binlog.000001 > /tmp/dump.sql mysqlbinlog --skip-gtids binlog.000002 >> /tmp/dump.sql mysql -u root -p -e "source /tmp/dump.sql"
The use of this option is otherwise not normally recommended in production.否则,通常不建议在生产中使用此选项。
--socket=
, path
-S
path
For connections to 对于与localhost
, the Unix socket file to use, or, on Windows, the name of the named pipe to use.localhost
的连接,使用Unix套接字文件,或者在Windows上,使用命名管道的名称。
On Windows, this option applies only if the server was started with the 在Windows上,此选项仅在服务器启动时启用了named_pipe
system variable enabled to support named-pipe connections. named_pipe
系统变量以支持命名管道连接时适用。In addition, the user making the connection must be a member of the Windows group specified by the 此外,进行连接的用户必须是named_pipe_full_access_group
system variable.named_pipe_full_access_group
系统变量指定的Windows组的成员。
Options that begin with 以--ssl
specify whether to connect to the server using encryption and indicate where to find SSL keys and certificates. See Command Options for Encrypted Connections.--ssl
开头的选项指定是否使用加密连接到服务器,并指示在哪里查找SSL密钥和证书。请参见加密连接的命令选项。
--ssl-fips-mode={OFF|ON|STRICT}
Controls whether to enable FIPS mode on the client side. 控制是否在客户端启用FIPS模式。The --ssl-fips-mode
option differs from other --ssl-
options in that it is not used to establish encrypted connections, but rather to affect which cryptographic operations to permit. See Section 6.8, “FIPS Support”.xxx
--ssl-fips-mode
选项与其他--ssl-xxx
选项的不同之处在于,它不用于建立加密连接,而是影响允许的加密操作。请参阅第6.8节,“FIPS支持”。
These 允许使用以下--ssl-fips-mode
values are permitted:--ssl-fips-mode
值:
OFF
: Disable FIPS mode.:禁用FIPS模式。
ON
: Enable FIPS mode.:启用FIPS模式。
STRICT
: Enable “strict” FIPS mode.:启用“严格”FIPS模式。
If the OpenSSL FIPS Object Module is not available, the only permitted value for 如果OpenSSL FIPS对象模块不可用,则--ssl-fips-mode
is OFF
. --ssl-fips-mode
的唯一允许值为OFF
。In this case, setting 在这种情况下,将--ssl-fips-mode
to ON
or STRICT
causes the client to produce a warning at startup and to operate in non-FIPS mode.--ssl-fips-mode
设置为ON
或STRICT
会导致客户端在启动时产生警告,并在非fips模式下运行。
Start reading the binary log at the first event having a timestamp equal to or later than the 从时间戳等于或晚于datetime
argument. datetime
参数的第一个事件开始读取二进制日志。The datetime
value is relative to the local time zone on the machine where you run mysqlbinlog. datetime
值相对于运行mysqlbinlog的计算机上的本地时区。The value should be in a format accepted for the 该值应采用DATETIME
or TIMESTAMP
data types. For example:DATETIME
或TIMESTAMP
数据类型可接受的格式。例如:
mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000003
This option is useful for point-in-time recovery. See Section 7.5, “Point-in-Time (Incremental) Recovery”.此选项对于时间点恢复非常有用。参阅第7.5节,“时间点(增量)恢复”。
--start-position=
, N
-j
N
Start decoding the binary log at the log position 从日志位置N
, including in the output any events that begin at position N
or after. N
开始解码二进制日志,在输出中包括从位置N
或之后开始的任何事件。The position is a byte point in the log file, not an event counter; it needs to point to the starting position of an event to generate useful output. This option applies to the first log file named on the command line.该位置是日志文件中的字节点,而不是事件计数器;它需要指向事件的起始位置以生成有用的输出。此选项适用于命令行上命名的第一个日志文件。
This option is useful for point-in-time recovery. See Section 7.5, “Point-in-Time (Incremental) Recovery”.此选项对于时间点恢复非常有用。参阅第7.5节,“时间点(增量)恢复”。
Stop reading the binary log at the first event having a timestamp equal to or later than the 在时间戳等于或晚于datetime
argument. datetime
参数的第一个事件时停止读取二进制日志。See the description of the 有关--start-datetime
option for information about the datetime
value.datetime
值的信息,请参阅--start-datetime
选项的描述。
This option is useful for point-in-time recovery. See Section 7.5, “Point-in-Time (Incremental) Recovery”.此选项对于时间点恢复非常有用。参阅第7.5节,“时间点(增量)恢复”。
This option is used with 此选项与--read-from-remote-server
. --read-from-remote-server
一起使用。It tells mysqlbinlog to remain connected to the server. 它告诉mysqlbinlog保持与服务器的连接。Otherwise mysqlbinlog exits when the last log file has been transferred from the server. 否则,当最后一个日志文件从服务器传输后,mysqlbinlog将退出。--stop-never
implies --to-last-log
, so only the first log file to transfer need be named on the command line.--stop-never
意味着--to-last-log
,因此只需要在命令行上命名要传输的第一个日志文件。
--stop-never
is commonly used with --raw
to make a live binary log backup, but also can be used without --raw
to maintain a continuous text display of log events as the server generates them.--stop-never
通常与--raw
一起使用,以制作实时二进制日志备份,但也可以在没有--raw
的情况下使用,以在服务器生成日志事件时保持日志事件的连续文本显示。
With 使用--stop-never
, by default, mysqlbinlog reports a server ID of 1 when it connects to the server. --stop-never
,默认情况下,mysqlbinlog在连接到服务器时报告服务器ID为1。Use 使用--connection-server-id
to explicitly specify an alternative ID to report. --connection-server-id
显式指定要报告的替代id。It can be used to avoid a conflict with the ID of a replica server or another mysqlbinlog process. 它可用于避免与副本服务器或另一个mysqlbinlog进程的ID冲突。See Section 4.6.9.4, “Specifying the mysqlbinlog Server ID”.请参阅第4.6.9.4节,“指定mysqlbinlog服务器ID”。
--stop-never-slave-server-id=
id
This option is deprecated; expect it to be removed in a future release. 此选项已弃用;预计它将在未来的版本中删除。Use the 使用--connection-server-id
option instead to specify a server ID for mysqlbinlog to report.--connection-server-id
选项来指定mysqlbinlog要报告的服务器ID。
Stop decoding the binary log at the log position 停止在日志位置N
, excluding from the output any events that begin at position N
or after. N
处解码二进制日志,从输出中排除从位置N或之后开始的任何事件。The position is a byte point in the log file, not an event counter; it needs to point to a spot after the starting position of the last event you want to include in the output. 该位置是日志文件中的字节点,而不是事件计数器;它需要指向输出中要包含的最后一个事件的起始位置之后的一个点。The event starting before position 在位置N之前开始并在该位置或之后结束的事件是最后一个要处理的事件。此选项适用于命令行上命名的最后一个日志文件。N
and finishing at or after the position is the last event to be processed. This option applies to the last log file named on the command line.
This option is useful for point-in-time recovery. See Section 7.5, “Point-in-Time (Incremental) Recovery”.此选项对于时间点恢复非常有用。参阅第7.5节,“时间点(增量)恢复”。
--tls-ciphersuites=
ciphersuite_list
The permissible ciphersuites for encrypted connections that use TLSv1.3. The value is a list of one or more colon-separated ciphersuite names. 允许的密码适用于使用TLSv1.3的加密连接。该值是一个或多个冒号分隔的密码套件名称的列表。The ciphersuites that can be named for this option depend on the SSL library used to compile MySQL. 可以为此选项命名的密码套件取决于用于编译MySQL的SSL库。For details, see Section 6.3.2, “Encrypted Connection TLS Protocols and Ciphers”.有关详细信息,请参阅第6.3.2节,“加密连接TLS协议和密码”。
This option was added in MySQL 8.0.16.此选项是在MySQL 8.0.16中添加的。
The permissible TLS protocols for encrypted connections. The value is a list of one or more comma-separated protocol names. 加密连接的允许TLS协议。该值是一个或多个逗号分隔的协议名称的列表。The protocols that can be named for this option depend on the SSL library used to compile MySQL. 可以为此选项命名的协议取决于用于编译MySQL的SSL库。For details, see Section 6.3.2, “Encrypted Connection TLS Protocols and Ciphers”.有关详细信息,请参阅第6.3.2节,“加密连接TLS协议和密码”。
--to-last-log
, -t
Do not stop at the end of the requested binary log from a MySQL server, but rather continue printing until the end of the last binary log. 不要在MySQL服务器请求的二进制日志结束时停止,而是继续打印,直到最后一个二进制日志结束。If you send the output to the same MySQL server, this may lead to an endless loop. 如果将输出发送到同一MySQL服务器,这可能会导致无休止的循环。This option requires 此选项需--read-from-remote-server
.--read-from-remote-server
。
--user=
, user_name
-u
user_name
The user name of the MySQL account to use when connecting to a remote server.连接到远程服务器时使用的MySQL帐户的用户名。
--verbose
, -v
Reconstruct row events and display them as commented SQL statements, with table partition information where applicable. 重建行事件并将其显示为带注释的SQL语句,并在适用的情况下显示表分区信息。If this option is given twice (by passing in either "-vv" or "--verbose --verbose"), the output includes comments to indicate column data types and some metadata, and informational log events such as row query log events if the 如果给出两次此选项(通过传入“-vv”或“--verbose-verbose”),则输出将包括用于指示列数据类型和一些元数据的注释,以及如果binlog_rows_query_log_events
system variable is set to TRUE
.binlog_rows_query_log_events
系统变量设置为TRUE
,则包括行查询日志事件等信息性日志事件。
For examples that show the effect of 有关--base64-output
and --verbose
on row event output, see Section 4.6.9.2, “mysqlbinlog Row Event Display”.--base64
输出和--verbose
对行事件输出的影响的示例,请参阅第4.6.9.2节,“mysqlbinlog行事件显示”。
Verify checksums in binary log files.验证二进制日志文件中的校验和。
--version
, -V
Display version information and exit.显示版本信息并退出。
The mysqlbinlog version number shown when using this option is 3.4.使用此选项时显示的mysqlbinlog版本号为3.4。
--zstd-compression-level=
level
The compression level to use for connections to the server that use the 用于连接到使用zstd
compression algorithm. The permitted levels are from 1 to 22, with larger values indicating increasing levels of compression. zstd
压缩算法的服务器的压缩级别。允许的级别为1到22,较大的值表示压缩级别增加。The default 默认的zstd
compression level is 3. The compression level setting has no effect on connections that do not use zstd
compression.zstd
压缩级别为3。压缩级别设置对不使用zstd
压缩的连接没有影响。
For more information, see Section 4.2.8, “Connection Compression Control”.有关更多信息,请参阅第4.2.8节,“连接压缩控制”。
This option was added in MySQL 8.0.18.此选项是在MySQL 8.0.18中添加的。
You can pipe the output of mysqlbinlog into the mysql client to execute the events contained in the binary log. 您可以将mysqlbinlog的输出通过管道传输到mysql客户端,以执行二进制日志中包含的事件。This technique is used to recover from an unexpected exit when you have an old backup (see Section 7.5, “Point-in-Time (Incremental) Recovery”). For example:当您有旧备份时,此技术用于从意外退出中恢复(请参阅第7.5节,“时间点(增量)恢复”)。例如:
mysqlbinlog binlog.000001 | mysql -u root -p
Or:或者:
mysqlbinlog binlog.[0-9]* | mysql -u root -p
If the statements produced by mysqlbinlog may contain 如果mysqlbinlog生成的语句可能包含BLOB
values, these may cause problems when mysql processes them. BLOB
值,则mysql处理这些值时可能会导致问题。In this case, invoke mysql with the 在这种情况下,使用--binary-mode
option.--binary
模式选项调用mysql。
You can also redirect the output of mysqlbinlog to a text file instead, if you need to modify the statement log first (for example, to remove statements that you do not want to execute for some reason). 如果需要先修改语句日志(例如,删除因某种原因不想执行的语句),您还可以将mysqlbinlog的输出重定向到文本文件。After editing the file, execute the statements that it contains by using it as input to the mysql program:编辑文件后,将其用作mysql程序的输入,执行其中包含的语句:
mysqlbinlog binlog.000001 > tmpfile
... edit tmpfile
...
mysql -u root -p < tmpfile
When mysqlbinlog is invoked with the 当使用--start-position
option, it displays only those events with an offset in the binary log greater than or equal to a given position (the given position must match the start of one event). --start-position
选项调用mysqlbinlog时,它只显示二进制日志中偏移量大于或等于给定位置的事件(给定位置必须与一个事件的开始匹配)。It also has options to stop and start when it sees an event with a given date and time. 它还可以选择在看到具有给定日期和时间的事件时停止和启动。This enables you to perform point-in-time recovery using the 这使您能够使用--stop-datetime
option (to be able to say, for example, “roll forward my databases to how they were today at 10:30 a.m.”).--stop-datetime
选项执行时间点恢复(例如,可以说“将我的数据库向前滚动到今天上午10:30的状态”)。
Processing multiple files.处理多个文件。 If you have more than one binary log to execute on the MySQL server, the safe method is to process them all using a single connection to the server. Here is an example that demonstrates what may be unsafe:如果你有多个二进制日志要在MySQL服务器上执行,安全的方法是使用到服务器的单个连接来处理它们。以下是一个示例,展示了可能存在的不安全因素:
mysqlbinlog binlog.000001 | mysql -u root -p # DANGER!! mysqlbinlog binlog.000002 | mysql -u root -p # DANGER!!
Processing binary logs this way using multiple connections to the server causes problems if the first log file contains a 如果第一个日志文件包含CREATE TEMPORARY TABLE
statement and the second log contains a statement that uses the temporary table. CREATE TEMPORARY TABLE
语句,而第二个日志包含使用临时表的语句,则使用到服务器的多个连接以这种方式处理二进制日志会导致问题。When the first mysql process terminates, the server drops the temporary table. 当第一个mysql进程终止时,服务器会删除临时表。When the second mysql process attempts to use the table, the server reports “unknown table.”当第二个mysql进程尝试使用该表时,服务器会报告“未知表”
To avoid problems like this, use a single mysql process to execute the contents of all binary logs that you want to process. Here is one way to do so:为了避免此类问题,请使用单个mysql进程来执行要处理的所有二进制日志的内容。以下是一种方法:
mysqlbinlog binlog.000001 binlog.000002 | mysql -u root -p
Another approach is to write all the logs to a single file and then process the file:另一种方法是将所有日志写入一个文件,然后处理该文件:
mysqlbinlog binlog.000001 > /tmp/statements.sql mysqlbinlog binlog.000002 >> /tmp/statements.sql mysql -u root -p -e "source /tmp/statements.sql"
From MySQL 8.0.12, you can also supply multiple binary log files to mysqlbinlog as streamed input using a shell pipe. 从MySQL 8.0.12开始,您还可以使用shell管道将多个二进制日志文件作为流式输入提供给mysqlbinlog。An archive of compressed binary log files can be decompressed and provided directly to mysqlbinlog. 压缩二进制日志文件的存档可以解压缩并直接提供给mysqlbinlog。In this example, 在这个例子中,binlog-files_1.gz
contains multiple binary log files for processing. binlog-files_1.gz
包含多个用于处理的二进制日志文件。The pipeline extracts the contents of 管道提取binlog-files_1.gz
, pipes the binary log files to mysqlbinlog as standard input, and pipes the output of mysqlbinlog into the mysql client for execution:binlog-files_1.gz
的内容,将二进制日志文件作为标准输入传输到mysqlbinlog,并将mysqlbinlog的输出传输到mysql客户端执行:
gzip -cd binlog-files_1.gz | ./mysqlbinlog - | ./mysql -uroot -p
You can specify more than one archive file, for example:您可以指定多个存档文件,例如:
gzip -cd binlog-files_1.gz binlog-files_2.gz | ./mysqlbinlog - | ./mysql -uroot -p
For streamed input, do not use 对于流式输入,不要使用--stop-position
, because mysqlbinlog cannot identify the last log file to apply this option.--stop-position
,因为mysqlbinlog无法识别应用此选项的最后一个日志文件。
LOAD DATA operations.操作。 mysqlbinlog can produce output that reproduces a mysqlbinlog可以生成输出,在没有原始数据文件的情况下再现LOAD DATA
operation without the original data file. LOAD DATA
操作。mysqlbinlog copies the data to a temporary file and writes a mysqlbinlog将数据复制到临时文件中,并写入引用该文件的LOAD DATA LOCAL
statement that refers to the file. LOAD DATA LOCAL
语句。The default location of the directory where these files are written is system-specific. 写入这些文件的目录的默认位置是特定于系统的。To specify a directory explicitly, use the 要显式指定目录,请使用--local-load
option.--local-load
选项。
Because mysqlbinlog converts 因为mysqlbinlog将LOAD DATA
statements to LOAD DATA LOCAL
statements (that is, it adds LOCAL
), both the client and the server that you use to process the statements must be configured with the LOCAL
capability enabled. LOAD DATA
语句转换为LOAD DATA LOCAL
语句(即,它添加了LOCAL
),所以用于处理语句的客户端和服务器都必须配置为启用LOCAL功能。See Section 6.1.6, “Security Considerations for LOAD DATA LOCAL”.请参阅第6.1.6节,“本地加载数据的安全考虑”。
The temporary files created for 为LOAD DATA LOCAL
statements are not automatically deleted because they are needed until you actually execute those statements. LOAD DATA LOCAL
语句创建的临时文件不会自动删除,因为在您实际执行这些语句之前需要它们。You should delete the temporary files yourself after you no longer need the statement log. The files can be found in the temporary file directory and have names like 在不再需要语句日志后,您应该自己删除临时文件。这些文件可以在临时文件目录中找到,其名称类似于original_file_name-#-#
.original_file_name-#-#
。