When invoked with the 当使用--read-from-remote-server
option, mysqlbinlog connects to a MySQL server, specifies a server ID to identify itself, and requests binary log files from the server. --read-from-remote-server
选项调用时,mysqlbinlog会连接到MySQL服务器,指定一个服务器ID来标识自己,并从服务器请求二进制日志文件。You can use mysqlbinlog to request log files from a server in several ways:您可以使用mysqlbinlog以多种方式从服务器请求日志文件:
Specify an explicitly named set of files: For each file, mysqlbinlog connects and issues a 指定一组明确命名的文件:对于每个文件,mysqlbinlog都会连接并发出Binlog转储命令。Binlog dump
command. The server sends the file and disconnects. There is one connection per file.服务器发送文件并断开连接。每个文件有一个连接。
Specify the beginning file and 指定起始文件和--to-last-log
: mysqlbinlog connects and issues a Binlog dump
command for all files. The server sends all files and disconnects.--to-last-log
:mysqlbinlog连接并为所有文件发出Binlog转储命令。服务器发送所有文件并断开连接。
Specify the beginning file and 指定起始文件和--stop-never
(which implies --to-last-log
): mysqlbinlog connects and issues a Binlog dump
command for all files. --stop-never
(这意味着--to-last-log
):mysqlbinlog连接并为所有文件发出Binlog转储命令。The server sends all files, but does not disconnect after sending the last one.服务器发送所有文件,但在发送最后一个文件后不会断开连接。
With 只使用--read-from-remote-server
only, mysqlbinlog connects using a server ID of 0, which tells the server to disconnect after sending the last requested log file.--read-from-remote-server
,mysqlbinlog使用服务器ID 0进行连接,该ID告诉服务器在发送最后一个请求的日志文件后断开连接。
With 使用--read-from-remote-server
and --stop-never
, mysqlbinlog connects using a nonzero server ID, so the server does not disconnect after sending the last log file. --read-from-remote-server
和--stop-never
,mysqlbinlog使用非零的服务器ID进行连接,因此服务器在发送最后一个日志文件后不会断开连接。The server ID is 1 by default, but this can be changed with 默认情况下,服务器ID为1,但可以使用--connection-server-id
.--connection-server-id
更改。
Thus, for the first two ways of requesting files, the server disconnects because mysqlbinlog specifies a server ID of 0. 因此,对于前两种请求文件的方式,服务器会断开连接,因为mysqlbinlog指定的服务器ID为0。It does not disconnect if 如果不给出--stop-never
is given because mysqlbinlog specifies a nonzero server ID.--stop-never
,则不会断开连接,因为mysqlbinlog指定了非零的服务器ID。