1MYSQLBINLOG(1)               MySQL Database System              MYSQLBINLOG(1)
2
3
4

NAME

6       mysqlbinlog - utility for processing binary log files
7

SYNOPSIS

9       mysqlbinlog [options] log_file ...
10

DESCRIPTION

12       The server's binary log consists of files containing “events” that
13       describe modifications to database contents. The server writes these
14       files in binary format. To display their contents in text format, use
15       the mysqlbinlog utility. You can also use mysqlbinlog to display the
16       contents of relay log files written by a slave server in a replication
17       setup because relay logs have the same format as binary logs. The
18       binary log and relay log are discussed further in Section 5.4.4, “The
19       Binary Log”, and Section 17.2.4, “Replication Relay and Status Logs”.
20
21       Invoke mysqlbinlog like this:
22
23           shell> mysqlbinlog [options] log_file ...
24
25       For example, to display the contents of the binary log file named
26       binlog.000003, use this command:
27
28           shell> mysqlbinlog binlog.0000003
29
30       The output includes events contained in binlog.000003. For
31       statement-based logging, event information includes the SQL statement,
32       the ID of the server on which it was executed, the timestamp when the
33       statement was executed, how much time it took, and so forth. For
34       row-based logging, the event indicates a row change rather than an SQL
35       statement. See Section 17.2.1, “Replication Formats”, for information
36       about logging modes.
37
38       Events are preceded by header comments that provide additional
39       information. For example:
40
41           # at 141
42           #100309  9:28:36 server id 123  end_log_pos 245
43             Query thread_id=3350  exec_time=11  error_code=0
44
45       In the first line, the number following at indicates the file offset,
46       or starting position, of the event in the binary log file.
47
48       The second line starts with a date and time indicating when the
49       statement started on the server where the event originated. For
50       replication, this timestamp is propagated to slave servers.  server id
51       is the server_id value of the server where the event originated.
52       end_log_pos indicates where the next event starts (that is, it is the
53       end position of the current event + 1).  thread_id indicates which
54       thread executed the event.  exec_time is the time spent executing the
55       event, on a master server. On a slave, it is the difference of the end
56       execution time on the slave minus the beginning execution time on the
57       master. The difference serves as an indicator of how much replication
58       lags behind the master.  error_code indicates the result from executing
59       the event. Zero means that no error occurred.
60
61           Note
62           When using event groups, the file offsets of events may be grouped
63           together and the comments of events may be grouped together. Do not
64           mistake these grouped events for blank file offsets.
65
66       The output from mysqlbinlog can be re-executed (for example, by using
67       it as input to mysql) to redo the statements in the log. This is useful
68       for recovery operations after a server crash. For other usage examples,
69       see the discussion later in this section and in Section 7.5, “Point-in-
70       Time (Incremental) Recovery Using the Binary Log”. To execute the
71       internal-use BINLOG statements used by mysqlbinlog, the user requires
72       the BINLOG_ADMIN or SUPER privilege, or the REPLICATION_APPLIER
73       privilege plus the appropriate privileges to execute each log event.
74
75       You can use mysqlbinlog to read binary log files directly and apply
76       them to the local MySQL server. You can also read binary logs from a
77       remote server by using the --read-from-remote-server option. To read
78       remote binary logs, the connection parameter options can be given to
79       indicate how to connect to the server. These options are --host,
80       --password, --port, --protocol, --socket, and --user.
81
82       When binary log files have been encrypted, which can be done from MySQL
83       8.0.14 onwards, mysqlbinlog cannot read them directly, but can read
84       them from the server using the --read-from-remote-server option. Binary
85       log files are encrypted when the server's binlog_encryption system
86       variable is set to ON. The SHOW BINARY LOGS statement shows whether a
87       particular binary log file is encrypted or unencrypted. Encrypted and
88       unencrypted binary log files can also be distinguished using the magic
89       number at the start of the file header for encrypted log files
90       (0xFD62696E), which differs from that used for unencrypted log files
91       (0xFE62696E). Note that from MySQL 8.0.14, mysqlbinlog returns a
92       suitable error if you attempt to read an encrypted binary log file
93       directly, but older versions of mysqlbinlog do not recognise the file
94       as a binary log file at all. For more information on binary log
95       encryption, see Section 17.3.2, “Encrypting Binary Log Files and Relay
96       Log Files”.
97
98       When running mysqlbinlog against a large binary log, be careful that
99       the filesystem has enough space for the resulting files. To configure
100       the directory that mysqlbinlog uses for temporary files, use the TMPDIR
101       environment variable.
102
103       mysqlbinlog sets the value of pseudo_slave_mode to true before
104       executing any SQL statements. This system variable affects the handling
105       of XA transactions, the original_commit_timestamp replication delay
106       timestamp and the original_server_version system variable, and
107       unsupported SQL modes.
108
109       mysqlbinlog supports the following options, which can be specified on
110       the command line or in the [mysqlbinlog] and [client] groups of an
111       option file. For information about option files used by MySQL programs,
112       see Section 4.2.2.2, “Using Option Files”.
113
114       ·   --help, -?
115
116           Display a help message and exit.
117
118       ·   --base64-output=value
119
120           This option determines when events should be displayed encoded as
121           base-64 strings using BINLOG statements. The option has these
122           permissible values (not case-sensitive):
123
124           ·   AUTO ("automatic") or UNSPEC ("unspecified") displays BINLOG
125               statements automatically when necessary (that is, for format
126               description events and row events). If no --base64-output
127               option is given, the effect is the same as
128               --base64-output=AUTO.
129
130                   Note
131                   Automatic BINLOG display is the only safe behavior if you
132                   intend to use the output of mysqlbinlog to re-execute
133                   binary log file contents. The other option values are
134                   intended only for debugging or testing purposes because
135                   they may produce output that does not include all events in
136                   executable form.
137
138           ·   NEVER causes BINLOG statements not to be displayed.
139               mysqlbinlog exits with an error if a row event is found that
140               must be displayed using BINLOG.
141
142           ·   DECODE-ROWS specifies to mysqlbinlog that you intend for row
143               events to be decoded and displayed as commented SQL statements
144               by also specifying the --verbose option. Like NEVER,
145               DECODE-ROWS suppresses display of BINLOG statements, but unlike
146               NEVER, it does not exit with an error if a row event is found.
147
148           For examples that show the effect of --base64-output and --verbose
149           on row event output, see the section called “MYSQLBINLOG ROW EVENT
150           DISPLAY”.
151
152       ·   --bind-address=ip_address
153
154           On a computer having multiple network interfaces, use this option
155           to select which interface to use for connecting to the MySQL
156           server.
157
158       ·   --binlog-row-event-max-size=N
159
160           ┌────────────────────┬─────────────────────────┐
161Property            Value                   
162           ├────────────────────┼─────────────────────────┤
163Command-Line Format │ --binlog-row-event-max- │
164           │                    │ size=#                  │
165           ├────────────────────┼─────────────────────────┤
166Type                │ Numeric                 │
167           ├────────────────────┼─────────────────────────┤
168Default Value       │ 4294967040              │
169           ├────────────────────┼─────────────────────────┤
170Minimum Value       │ 256                     │
171           ├────────────────────┼─────────────────────────┤
172Maximum Value       │ 18446744073709547520    │
173           └────────────────────┴─────────────────────────┘
174           Specify the maximum size of a row-based binary log event, in bytes.
175           Rows are grouped into events smaller than this size if possible.
176           The value should be a multiple of 256. The default is 4GB.
177
178       ·   --character-sets-dir=dir_name
179
180           The directory where character sets are installed. See
181           Section 10.15, “Character Set Configuration”.
182
183       ·   --compress
184
185           Compress all information sent between the client and the server if
186           possible. See Section 4.2.6, “Connection Compression Control”.
187
188           This option was added in MySQL 8.0.17. As of MySQL 8.0.18 it is
189           deprecated. It will be removed in a future MySQL version. See the
190           section called “Legacy Connection Compression Configuration”.
191
192       ·   --compression-algorithms=value The permitted compression algorithms
193           for connections to the server. The available algorithms are the
194           same as for the protocol_compression_algorithms system variable.
195           The default value is uncompressed.
196
197           For more information, see Section 4.2.6, “Connection Compression
198           Control”.
199
200           This option was added in MySQL 8.0.18.
201
202       ·   --connection-server-id=server_id
203
204           --connection-server-id specifies the server ID that mysqlbinlog
205           reports when it connects to the server. It can be used to avoid a
206           conflict with the ID of a slave server or another mysqlbinlog
207           process.
208
209           If the --read-from-remote-server option is specified, mysqlbinlog
210           reports a server ID of 0, which tells the server to disconnect
211           after sending the last log file (nonblocking behavior). If the
212           --stop-never option is also specified to maintain the connection to
213           the server, mysqlbinlog reports a server ID of 1 by default instead
214           of 0, and --connection-server-id can be used to replace that server
215           ID if required. See the section called “SPECIFYING THE MYSQLBINLOG
216           SERVER ID”.
217
218       ·   --database=db_name, -d db_name
219
220           This option causes mysqlbinlog to output entries from the binary
221           log (local log only) that occur while db_name is been selected as
222           the default database by USE.
223
224           The --database option for mysqlbinlog is similar to the
225           --binlog-do-db option for mysqld, but can be used to specify only
226           one database. If --database is given multiple times, only the last
227           instance is used.
228
229           The effects of this option depend on whether the statement-based or
230           row-based logging format is in use, in the same way that the
231           effects of --binlog-do-db depend on whether statement-based or
232           row-based logging is in use.
233
234           Statement-based logging. The --database option works as follows:
235
236           ·   While db_name is the default database, statements are output
237               whether they modify tables in db_name or a different database.
238
239           ·   Unless db_name is selected as the default database, statements
240               are not output, even if they modify tables in db_name.
241
242           ·   There is an exception for CREATE DATABASE, ALTER DATABASE, and
243               DROP DATABASE. The database being created, altered, or dropped
244               is considered to be the default database when determining
245               whether to output the statement.
246
247           Suppose that the binary log was created by executing these
248           statements using statement-based-logging:
249
250               INSERT INTO test.t1 (i) VALUES(100);
251               INSERT INTO db2.t2 (j)  VALUES(200);
252               USE test;
253               INSERT INTO test.t1 (i) VALUES(101);
254               INSERT INTO t1 (i)      VALUES(102);
255               INSERT INTO db2.t2 (j)  VALUES(201);
256               USE db2;
257               INSERT INTO test.t1 (i) VALUES(103);
258               INSERT INTO db2.t2 (j)  VALUES(202);
259               INSERT INTO t2 (j)      VALUES(203);
260
261           mysqlbinlog --database=test does not output the first two INSERT
262           statements because there is no default database. It outputs the
263           three INSERT statements following USE test, but not the three
264           INSERT statements following USE db2.
265
266           mysqlbinlog --database=db2 does not output the first two INSERT
267           statements because there is no default database. It does not output
268           the three INSERT statements following USE test, but does output the
269           three INSERT statements following USE db2.
270
271           Row-based logging. mysqlbinlog outputs only entries that change
272           tables belonging to db_name. The default database has no effect on
273           this. Suppose that the binary log just described was created using
274           row-based logging rather than statement-based logging.  mysqlbinlog
275           --database=test outputs only those entries that modify t1 in the
276           test database, regardless of whether USE was issued or what the
277           default database is.  If a server is running with binlog_format set
278           to MIXED and you want it to be possible to use mysqlbinlog with the
279           --database option, you must ensure that tables that are modified
280           are in the database selected by USE. (In particular, no
281           cross-database updates should be used.)
282
283           When used together with the --rewrite-db option, the --rewrite-db
284           option is applied first; then the --database option is applied,
285           using the rewritten database name. The order in which the options
286           are provided makes no difference in this regard.
287
288       ·   --debug[=debug_options], -# [debug_options]
289
290           Write a debugging log. A typical debug_options string is
291           d:t:o,file_name. The default is d:t:o,/tmp/mysqlbinlog.trace.
292
293           This option is available only if MySQL was built using WITH_DEBUG.
294           MySQL release binaries provided by Oracle are not built using this
295           option.
296
297       ·   --debug-check
298
299           Print some debugging information when the program exits.
300
301           This option is available only if MySQL was built using WITH_DEBUG.
302           MySQL release binaries provided by Oracle are not built using this
303           option.
304
305       ·   --debug-info
306
307           Print debugging information and memory and CPU usage statistics
308           when the program exits.
309
310           This option is available only if MySQL was built using WITH_DEBUG.
311           MySQL release binaries provided by Oracle are not built using this
312           option.
313
314       ·   --default-auth=plugin
315
316           A hint about which client-side authentication plugin to use. See
317           Section 6.2.17, “Pluggable Authentication”.
318
319       ·   --defaults-extra-file=file_name
320
321           Read this option file after the global option file but (on Unix)
322           before the user option file. If the file does not exist or is
323           otherwise inaccessible, an error occurs.  file_name is interpreted
324           relative to the current directory if given as a relative path name
325           rather than a full path name.
326
327           For additional information about this and other option-file
328           options, see Section 4.2.2.3, “Command-Line Options that Affect
329           Option-File Handling”.
330
331       ·   --defaults-file=file_name
332
333           Use only the given option file. If the file does not exist or is
334           otherwise inaccessible, an error occurs.  file_name is interpreted
335           relative to the current directory if given as a relative path name
336           rather than a full path name.
337
338           Exception: Even with --defaults-file, client programs read
339           .mylogin.cnf.
340
341           For additional information about this and other option-file
342           options, see Section 4.2.2.3, “Command-Line Options that Affect
343           Option-File Handling”.
344
345       ·   --defaults-group-suffix=str
346
347           Read not only the usual option groups, but also groups with the
348           usual names and a suffix of str. For example, mysqlbinlog normally
349           reads the [client] and [mysqlbinlog] groups. If the
350           --defaults-group-suffix=_other option is given, mysqlbinlog also
351           reads the [client_other] and [mysqlbinlog_other] groups.
352
353           For additional information about this and other option-file
354           options, see Section 4.2.2.3, “Command-Line Options that Affect
355           Option-File Handling”.
356
357       ·   --disable-log-bin, -D
358
359           Disable binary logging. This is useful for avoiding an endless loop
360           if you use the --to-last-log option and are sending the output to
361           the same MySQL server. This option also is useful when restoring
362           after a crash to avoid duplication of the statements you have
363           logged.
364
365           This option causes mysqlbinlog to include a SET sql_log_bin = 0
366           statement in its output to disable binary logging of the remaining
367           output. Manipulating the session value of the sql_log_bin system
368           variable is a restricted operation, so this option requires that
369           you have privileges sufficient to set restricted session variables.
370           See Section 5.1.9.1, “System Variable Privileges”.
371
372       ·   --exclude-gtids=gtid_set
373
374           Do not display any of the groups listed in the gtid_set.
375
376       ·   --force-if-open, -F
377
378           Read binary log files even if they are open or were not closed
379           properly.
380
381       ·   --force-read, -f
382
383           With this option, if mysqlbinlog reads a binary log event that it
384           does not recognize, it prints a warning, ignores the event, and
385           continues. Without this option, mysqlbinlog stops if it reads such
386           an event.
387
388       ·   --get-server-public-key
389
390           Request from the server the public key required for RSA key
391           pair-based password exchange. This option applies to clients that
392           authenticate with the caching_sha2_password authentication plugin.
393           For that plugin, the server does not send the public key unless
394           requested. This option is ignored for accounts that do not
395           authenticate with that plugin. It is also ignored if RSA-based
396           password exchange is not used, as is the case when the client
397           connects to the server using a secure connection.
398
399           If --server-public-key-path=file_name is given and specifies a
400           valid public key file, it takes precedence over
401           --get-server-public-key.
402
403           For information about the caching_sha2_password plugin, see
404           Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
405
406       ·   --hexdump, -H
407
408           Display a hex dump of the log in comments, as described in the
409           section called “MYSQLBINLOG HEX DUMP FORMAT”. The hex output can be
410           helpful for replication debugging.
411
412       ·   --host=host_name, -h host_name
413
414           Get the binary log from the MySQL server on the given host.
415
416       ·   --idempotent
417
418           Tell the MySQL Server to use idempotent mode while processing
419           updates; this causes suppression of any duplicate-key or
420           key-not-found errors that the server encounters in the current
421           session while processing updates. This option may prove useful
422           whenever it is desirable or necessary to replay one or more binary
423           logs to a MySQL Server which may not contain all of the data to
424           which the logs refer.
425
426           The scope of effect for this option includes the current
427           mysqlbinlog client and session only.
428
429       ·   --include-gtids=gtid_set
430
431           Display only the groups listed in the gtid_set.
432
433       ·   --local-load=dir_name, -l dir_name
434
435           Prepare local temporary files for LOAD DATA in the specified
436           directory.
437
438               Important
439               These temporary files are not automatically removed by
440               mysqlbinlog or any other MySQL program.
441
442       ·   --login-path=name
443
444           Read options from the named login path in the .mylogin.cnf login
445           path file. A “login path” is an option group containing options
446           that specify which MySQL server to connect to and which account to
447           authenticate as. To create or modify a login path file, use the
448           mysql_config_editor utility. See mysql_config_editor(1).
449
450           For additional information about this and other option-file
451           options, see Section 4.2.2.3, “Command-Line Options that Affect
452           Option-File Handling”.
453
454       ·   --no-defaults
455
456           Do not read any option files. If program startup fails due to
457           reading unknown options from an option file, --no-defaults can be
458           used to prevent them from being read.
459
460           The exception is that the .mylogin.cnf file, if it exists, is read
461           in all cases. This permits passwords to be specified in a safer way
462           than on the command line even when --no-defaults is used.
463           (.mylogin.cnf is created by the mysql_config_editor utility. See
464           mysql_config_editor(1).)
465
466           For additional information about this and other option-file
467           options, see Section 4.2.2.3, “Command-Line Options that Affect
468           Option-File Handling”.
469
470       ·   --offset=N, -o N
471
472           Skip the first N entries in the log.
473
474       ·   --open-files-limit=N Specify the number of open file descriptors to
475           reserve.
476
477       ·   --password[=password], -p[password]
478
479           The password of the MySQL account used for connecting to the
480           server. The password value is optional. If not given, mysqlbinlog
481           prompts for one. If given, there must be no space between
482           --password= or -p and the password following it. If no password
483           option is specified, the default is to send no password.
484
485           Specifying a password on the command line should be considered
486           insecure. To avoid giving the password on the command line, use an
487           option file. See Section 6.1.2.1, “End-User Guidelines for Password
488           Security”.
489
490           To explicitly specify that there is no password and that
491           mysqlbinlog should not prompt for one, use the --skip-password
492           option.
493
494       ·   --plugin-dir=dir_name
495
496           The directory in which to look for plugins. Specify this option if
497           the --default-auth option is used to specify an authentication
498           plugin but mysqlbinlog does not find it. See Section 6.2.17,
499           “Pluggable Authentication”.
500
501       ·   --port=port_num, -P port_num
502
503           The TCP/IP port number to use for connecting to a remote server.
504
505       ·   --print-defaults
506
507           Print the program name and all options that it gets from option
508           files.
509
510           For additional information about this and other option-file
511           options, see Section 4.2.2.3, “Command-Line Options that Affect
512           Option-File Handling”.
513
514       ·   --print-table-metadata
515
516           Print table related metadata from the binary log. Configure the
517           amount of table related metadata binary logged using
518           binlog-row-metadata.
519
520       ·   --protocol={TCP|SOCKET|PIPE|MEMORY}
521
522           The connection protocol to use for connecting to the server. It is
523           useful when the other connection parameters normally result in use
524           of a protocol other than the one you want. For details on the
525           permissible values, see Section 4.2.4, “Connecting to the MySQL
526           Server Using Command Options”.
527
528       ·   --raw
529
530           By default, mysqlbinlog reads binary log files and writes events in
531           text format. The --raw option tells mysqlbinlog to write them in
532           their original binary format. Its use requires that
533           --read-from-remote-server also be used because the files are
534           requested from a server.  mysqlbinlog writes one output file for
535           each file read from the server. The --raw option can be used to
536           make a backup of a server's binary log. With the --stop-never
537           option, the backup is “live” because mysqlbinlog stays connected to
538           the server. By default, output files are written in the current
539           directory with the same names as the original log files. Output
540           file names can be modified using the --result-file option. For more
541           information, see the section called “USING MYSQLBINLOG TO BACK UP
542           BINARY LOG FILES”.
543
544       ·   --read-from-remote-master=type
545
546           Read binary logs from a MySQL server with the COM_BINLOG_DUMP or
547           COM_BINLOG_DUMP_GTID commands by setting the option value to either
548           BINLOG-DUMP-NON-GTIDS or BINLOG-DUMP-GTIDS, respectively. If
549           --read-from-remote-master=BINLOG-DUMP-GTIDS is combined with
550           --exclude-gtids, transactions can be filtered out on the master,
551           avoiding unnecessary network traffic.
552
553           The connection parameter options are used with this option or the
554           --read-from-remote-server option. These options are --host,
555           --password, --port, --protocol, --socket, and --user. If neither of
556           the remote options is specified, the connection parameter options
557           are ignored.
558
559           The REPLICATION SLAVE privilege is required to use this option.
560
561       ·   --read-from-remote-server, -R
562
563           Read the binary log from a MySQL server rather than reading a local
564           log file. This option requires that the remote server be running.
565           It works only for binary log files on the remote server, not relay
566           log files.
567
568           The connection parameter options are used with this option or the
569           --read-from-remote-master option. These options are --host,
570           --password, --port, --protocol, --socket, and --user. If neither of
571           the remote options is specified, the connection parameter options
572           are ignored.
573
574           The REPLICATION SLAVE privilege is required to use this option.
575
576           This option is like
577           --read-from-remote-master=BINLOG-DUMP-NON-GTIDS.
578
579       ·   --result-file=name, -r name
580
581           Without the --raw option, this option indicates the file to which
582           mysqlbinlog writes text output. With --raw, mysqlbinlog writes one
583           binary output file for each log file transferred from the server,
584           writing them by default in the current directory using the same
585           names as the original log file. In this case, the --result-file
586           option value is treated as a prefix that modifies output file
587           names.
588
589       ·   --require-row-format
590
591           Require row-based binary logging format for events. This option
592           enforces row-based replication events for mysqlbinlog output. The
593           stream of events produced with this option would be accepted by a
594           replication channel that is secured using the REQUIRE_ROW_FORMAT
595           option of the CHANGE MASTER TO statement.  binlog_format=ROW must
596           be set on the server where the binary log was written. When you
597           specify this option, mysqlbinlog stops with an error message if it
598           encounters any events that are disallowed under the
599           REQUIRE_ROW_FORMAT restrictions, including LOAD DATA INFILE
600           instructions, creating or dropping temporary tables, INTVAR, RAND,
601           or USER_VAR events, and non-row-based events within a DML
602           transaction.  mysqlbinlog also prints a SET
603           @@session.require_row_format statement at the start of its output
604           to apply the restrictions when the output is executed, and does not
605           print the SET @@session.pseudo_thread_id statement.
606
607           This option was added in MySQL 8.0.19.
608
609       ·   --rewrite-db='from_name->to_name'
610
611           When reading from a row-based or statement-based log, rewrite all
612           occurrences of from_name to to_name. Rewriting is done on the rows,
613           for row-based logs, as well as on the USE clauses, for
614           statement-based logs.
615
616               Warning
617               Statements in which table names are qualified with database
618               names are not rewritten to use the new name when using this
619               option.
620           The rewrite rule employed as a value for this option is a string
621           having the form 'from_name->to_name', as shown previously, and for
622           this reason must be enclosed by quotation marks.
623
624           To employ multiple rewrite rules, specify the option multiple
625           times, as shown here:
626
627               shell> mysqlbinlog --rewrite-db='dbcurrent->dbold' --rewrite-db='dbtest->dbcurrent' \
628                                    binlog.00001 > /tmp/statements.sql
629
630           When used together with the --database option, the --rewrite-db
631           option is applied first; then --database option is applied, using
632           the rewritten database name. The order in which the options are
633           provided makes no difference in this regard.
634
635           This means that, for example, if mysqlbinlog is started with
636           --rewrite-db='mydb->yourdb' --database=yourdb, then all updates to
637           any tables in databases mydb and yourdb are included in the output.
638           On the other hand, if it is started with
639           --rewrite-db='mydb->yourdb' --database=mydb, then mysqlbinlog
640           outputs no statements at all: since all updates to mydb are first
641           rewritten as updates to yourdb before applying the --database
642           option, there remain no updates that match --database=mydb.
643
644       ·   --server-id=id
645
646           Display only those events created by the server having the given
647           server ID.
648
649       ·   --server-id-bits=N
650
651           Use only the first N bits of the server_id to identify the server.
652           If the binary log was written by a mysqld with server-id-bits set
653           to less than 32 and user data stored in the most significant bit,
654           running mysqlbinlog with --server-id-bits set to 32 enables this
655           data to be seen.
656
657           This option is supported only by the version of mysqlbinlog
658           supplied with the NDB Cluster distribution, or built with NDB
659           Cluster support.
660
661       ·   --server-public-key-path=file_name
662
663           The path name to a file containing a client-side copy of the public
664           key required by the server for RSA key pair-based password
665           exchange. The file must be in PEM format. This option applies to
666           clients that authenticate with the sha256_password or
667           caching_sha2_password authentication plugin. This option is ignored
668           for accounts that do not authenticate with one of those plugins. It
669           is also ignored if RSA-based password exchange is not used, as is
670           the case when the client connects to the server using a secure
671           connection.
672
673           If --server-public-key-path=file_name is given and specifies a
674           valid public key file, it takes precedence over
675           --get-server-public-key.
676
677           For sha256_password, this option applies only if MySQL was built
678           using OpenSSL.
679
680           For information about the sha256_password and caching_sha2_password
681           plugins, see Section 6.4.1.3, “SHA-256 Pluggable Authentication”,
682           and Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
683
684       ·   --set-charset=charset_name
685
686           Add a SET NAMES charset_name statement to the output to specify the
687           character set to be used for processing log files.
688
689       ·   --shared-memory-base-name=name
690
691           On Windows, the shared-memory name to use for connections made
692           using shared memory to a local server. The default value is MYSQL.
693           The shared-memory name is case-sensitive.
694
695           This option applies only if the server was started with the
696           shared_memory system variable enabled to support shared-memory
697           connections.
698
699       ·   --short-form, -s
700
701           Display only the statements contained in the log, without any extra
702           information or row-based events. This is for testing only, and
703           should not be used in production systems. It is deprecated, and
704           will be removed in a future release.
705
706       ·   --skip-gtids[=(true|false)]
707
708           Do not display any GTIDs in the output. This is needed when writing
709           to a dump file from one or more binary logs containing GTIDs, as
710           shown in this example:
711
712               shell> mysqlbinlog --skip-gtids binlog.000001 >  /tmp/dump.sql
713               shell> mysqlbinlog --skip-gtids binlog.000002 >> /tmp/dump.sql
714               shell> mysql -u root -p -e "source /tmp/dump.sql"
715
716           The use of this option is otherwise not normally recommended in
717           production.
718
719       ·   --socket=path, -S path
720
721           For connections to localhost, the Unix socket file to use, or, on
722           Windows, the name of the named pipe to use.
723
724           On Windows, this option applies only if the server was started with
725           the named_pipe system variable enabled to support named-pipe
726           connections. In addition, the user making the connection must be a
727           member of the Windows group specified by the
728           named_pipe_full_access_group system variable.
729
730       ·   --ssl*
731
732           Options that begin with --ssl specify whether to connect to the
733           server using SSL and indicate where to find SSL keys and
734           certificates. See the section called “Command Options for Encrypted
735           Connections”.
736
737       ·   --ssl-fips-mode={OFF|ON|STRICT} Controls whether to enable FIPS
738           mode on the client side. The --ssl-fips-mode option differs from
739           other --ssl-xxx options in that it is not used to establish
740           encrypted connections, but rather to affect which cryptographic
741           operations are permitted. See Section 6.5, “FIPS Support”.
742
743           These --ssl-fips-mode values are permitted:
744
745           ·   OFF: Disable FIPS mode.
746
747           ·   ON: Enable FIPS mode.
748
749           ·   STRICT: Enable “strict” FIPS mode.
750
751
752               Note
753               If the OpenSSL FIPS Object Module is not available, the only
754               permitted value for --ssl-fips-mode is OFF. In this case,
755               setting --ssl-fips-mode to ON or STRICT causes the client to
756               produce a warning at startup and to operate in non-FIPS mode.
757
758       ·   --start-datetime=datetime
759
760           Start reading the binary log at the first event having a timestamp
761           equal to or later than the datetime argument. The datetime value is
762           relative to the local time zone on the machine where you run
763           mysqlbinlog. The value should be in a format accepted for the
764           DATETIME or TIMESTAMP data types. For example:
765
766               shell> mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000003
767
768           This option is useful for point-in-time recovery. See Section 7.3,
769           “Example Backup and Recovery Strategy”.
770
771       ·   --start-position=N, -j N
772
773           Start reading the binary log at the first event having a position
774           equal to or greater than N. This option applies to the first log
775           file named on the command line.
776
777           This option is useful for point-in-time recovery. See Section 7.3,
778           “Example Backup and Recovery Strategy”.
779
780       ·   --stop-datetime=datetime
781
782           Stop reading the binary log at the first event having a timestamp
783           equal to or later than the datetime argument. This option is useful
784           for point-in-time recovery. See the description of the
785           --start-datetime option for information about the datetime value.
786
787           This option is useful for point-in-time recovery. See Section 7.3,
788           “Example Backup and Recovery Strategy”.
789
790       ·   --stop-never
791
792           This option is used with --read-from-remote-server. It tells
793           mysqlbinlog to remain connected to the server. Otherwise
794           mysqlbinlog exits when the last log file has been transferred from
795           the server.  --stop-never implies --to-last-log, so only the first
796           log file to transfer need be named on the command line.
797
798           --stop-never is commonly used with --raw to make a live binary log
799           backup, but also can be used without --raw to maintain a continuous
800           text display of log events as the server generates them.
801
802           With --stop-never, by default, mysqlbinlog reports a server ID of 1
803           when it connects to the server. Use --connection-server-id to
804           explicitly specify an alternative ID to report. It can be used to
805           avoid a conflict with the ID of a slave server or another
806           mysqlbinlog process. See the section called “SPECIFYING THE
807           MYSQLBINLOG SERVER ID”.
808
809       ·   --stop-never-slave-server-id=id
810
811           This option is deprecated and will be removed in a future release.
812           Use the --connection-server-id option instead to specify a server
813           ID for mysqlbinlog to report.
814
815       ·   --stop-position=N
816
817           Stop reading the binary log at the first event having a position
818           equal to or greater than N. This option applies to the last log
819           file named on the command line.
820
821           This option is useful for point-in-time recovery. See Section 7.3,
822           “Example Backup and Recovery Strategy”.
823
824       ·   --tls-ciphersuites=ciphersuite_list
825
826           The permissible ciphersuites for encrypted connections that use
827           TLSv1.3. The value is a list of one or more colon-separated
828           ciphersuite names. The ciphersuites that can be named for this
829           option depend on the SSL library used to compile MySQL. For
830           details, see Section 6.3.2, “Encrypted Connection TLS Protocols and
831           Ciphers”.
832
833           This option was added in MySQL 8.0.16.
834
835       ·   --tls-version=protocol_list
836
837           The permissible TLS protocols for encrypted connections. The value
838           is a list of one or more comma-separated protocol names. The
839           protocols that can be named for this option depend on the SSL
840           library used to compile MySQL. For details, see Section 6.3.2,
841           “Encrypted Connection TLS Protocols and Ciphers”.
842
843       ·   --to-last-log, -t
844
845           Do not stop at the end of the requested binary log from a MySQL
846           server, but rather continue printing until the end of the last
847           binary log. If you send the output to the same MySQL server, this
848           may lead to an endless loop. This option requires
849           --read-from-remote-server.
850
851       ·   --user=user_name, -u user_name
852
853           The user name of the MySQL account to use when connecting to a
854           remote server.
855
856       ·   --verbose, -v
857
858           Reconstruct row events and display them as commented SQL
859           statements, with table partition information where applicable. If
860           this option is given twice (by passing in either "-vv" or
861           "--verbose --verbose"), the output includes comments to indicate
862           column data types and some metadata, and informational log events
863           such as row query log events if the binlog_rows_query_log_events
864           system variable is set to TRUE.
865
866           For examples that show the effect of --base64-output and --verbose
867           on row event output, see the section called “MYSQLBINLOG ROW EVENT
868           DISPLAY”.
869
870       ·   --verify-binlog-checksum, -c
871
872           Verify checksums in binary log files.
873
874       ·   --version, -V
875
876           Display version information and exit.
877
878           The mysqlbinlog version number shown when using this option is 3.4.
879
880       ·   --zstd-compression-level=level The compression level to use for
881           connections to the server that use the zstd compression algorithm.
882           The permitted levels are from 1 to 22, with larger values
883           indicating increasing levels of compression. The default zstd
884           compression level is 3. The compression level setting has no effect
885           on connections that do not use zstd compression.
886
887           For more information, see Section 4.2.6, “Connection Compression
888           Control”.
889
890           This option was added in MySQL 8.0.18.
891
892       You can pipe the output of mysqlbinlog into the mysql client to execute
893       the events contained in the binary log. This technique is used to
894       recover from a crash when you have an old backup (see Section 7.5,
895       “Point-in-Time (Incremental) Recovery Using the Binary Log”). For
896       example:
897
898           shell> mysqlbinlog binlog.000001 | mysql -u root -p
899
900       Or:
901
902           shell> mysqlbinlog binlog.[0-9]* | mysql -u root -p
903
904       If the statements produced by mysqlbinlog may contain BLOB values,
905       these may cause problems when mysql processes them. In this case,
906       invoke mysql with the --binary-mode option.
907
908       You can also redirect the output of mysqlbinlog to a text file instead,
909       if you need to modify the statement log first (for example, to remove
910       statements that you do not want to execute for some reason). After
911       editing the file, execute the statements that it contains by using it
912       as input to the mysql program:
913
914           shell> mysqlbinlog binlog.000001 > tmpfile
915           shell> ... edit tmpfile ...
916           shell> mysql -u root -p < tmpfile
917
918       When mysqlbinlog is invoked with the --start-position option, it
919       displays only those events with an offset in the binary log greater
920       than or equal to a given position (the given position must match the
921       start of one event). It also has options to stop and start when it sees
922       an event with a given date and time. This enables you to perform
923       point-in-time recovery using the --stop-datetime option (to be able to
924       say, for example, “roll forward my databases to how they were today at
925       10:30 a.m.”).
926
927       Processing multiple files. If you have more than one binary log to
928       execute on the MySQL server, the safe method is to process them all
929       using a single connection to the server. Here is an example that
930       demonstrates what may be unsafe:
931
932           shell> mysqlbinlog binlog.000001 | mysql -u root -p # DANGER!!
933           shell> mysqlbinlog binlog.000002 | mysql -u root -p # DANGER!!
934
935       Processing binary logs this way using multiple connections to the
936       server causes problems if the first log file contains a CREATE
937       TEMPORARY TABLE statement and the second log contains a statement that
938       uses the temporary table. When the first mysql process terminates, the
939       server drops the temporary table. When the second mysql process
940       attempts to use the table, the server reports “unknown table.”
941
942       To avoid problems like this, use a single mysql process to execute the
943       contents of all binary logs that you want to process. Here is one way
944       to do so:
945
946           shell> mysqlbinlog binlog.000001 binlog.000002 | mysql -u root -p
947
948       Another approach is to write all the logs to a single file and then
949       process the file:
950
951           shell> mysqlbinlog binlog.000001 >  /tmp/statements.sql
952           shell> mysqlbinlog binlog.000002 >> /tmp/statements.sql
953           shell> mysql -u root -p -e "source /tmp/statements.sql"
954
955       From MySQL 8.0.12, you can also supply multiple binary log files to
956       mysqlbinlog as streamed input using a shell pipe. An archive of
957       compressed binary log files can be decompressed and provided directly
958       to mysqlbinlog. In this example, binlog-files_1.gz contains multiple
959       binary log files for processing. The pipeline extracts the contents of
960       binlog-files_1.gz, pipes the binary log files to mysqlbinlog as
961       standard input, and pipes the output of mysqlbinlog into the mysql
962       client for execution:
963
964           shell> gzip -cd binlog-files_1.gz | ./mysqlbinlog - | ./mysql -uroot  -p
965
966       You can specify more than one archive file, for example:
967
968           shell> gzip -cd binlog-files_1.gz binlog-files_2.gz | ./mysqlbinlog - | ./mysql -uroot  -p
969
970       For streamed input, do not use --stop-position, because mysqlbinlog
971       cannot identify the last log file to apply this option.
972
973       LOAD DATA operations. mysqlbinlog can produce output that reproduces a
974       LOAD DATA operation without the original data file.  mysqlbinlog copies
975       the data to a temporary file and writes a LOAD DATA LOCAL statement
976       that refers to the file. The default location of the directory where
977       these files are written is system-specific. To specify a directory
978       explicitly, use the --local-load option.
979
980       Because mysqlbinlog converts LOAD DATA statements to LOAD DATA LOCAL
981       statements (that is, it adds LOCAL), both the client and the server
982       that you use to process the statements must be configured with the
983       LOCAL capability enabled. See Section 6.1.6, “Security Issues with LOAD
984       DATA LOCAL”.
985
986           Warning
987           The temporary files created for LOAD DATA LOCAL statements are not
988           automatically deleted because they are needed until you actually
989           execute those statements. You should delete the temporary files
990           yourself after you no longer need the statement log. The files can
991           be found in the temporary file directory and have names like
992           original_file_name-#-#.
993

MYSQLBINLOG HEX DUMP FORMAT

995       The --hexdump option causes mysqlbinlog to produce a hex dump of the
996       binary log contents:
997
998           shell> mysqlbinlog --hexdump master-bin.000001
999
1000       The hex output consists of comment lines beginning with #, so the
1001       output might look like this for the preceding command:
1002
1003           /*!40019 SET @@SESSION.max_insert_delayed_threads=0*/;
1004           /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1005           # at 4
1006           #051024 17:24:13 server id 1  end_log_pos 98
1007           # Position  Timestamp   Type   Master ID        Size      Master Pos    Flags
1008           # 00000004 9d fc 5c 43   0f   01 00 00 00   5e 00 00 00   62 00 00 00   00 00
1009           # 00000017 04 00 35 2e 30 2e 31 35  2d 64 65 62 75 67 2d 6c |..5.0.15.debug.l|
1010           # 00000027 6f 67 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |og..............|
1011           # 00000037 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
1012           # 00000047 00 00 00 00 9d fc 5c 43  13 38 0d 00 08 00 12 00 |.......C.8......|
1013           # 00000057 04 04 04 04 12 00 00 4b  00 04 1a                |.......K...|
1014           #       Start: binlog v 4, server v 5.0.15-debug-log created 051024 17:24:13
1015           #       at startup
1016           ROLLBACK;
1017
1018       Hex dump output currently contains the elements in the following list.
1019       This format is subject to change. For more information about binary log
1020       format, see MySQL Internals: The Binary Log[1].
1021
1022       ·   Position: The byte position within the log file.
1023
1024       ·   Timestamp: The event timestamp. In the example shown, '9d fc 5c 43'
1025           is the representation of '051024 17:24:13' in hexadecimal.
1026
1027       ·   Type: The event type code.
1028
1029       ·   Master ID: The server ID of the master that created the event.
1030
1031       ·   Size: The size in bytes of the event.
1032
1033       ·   Master Pos: The position of the next event in the original master
1034           log file.
1035
1036       ·   Flags: Event flag values.
1037

MYSQLBINLOG ROW EVENT DISPLAY

1039       The following examples illustrate how mysqlbinlog displays row events
1040       that specify data modifications. These correspond to events with the
1041       WRITE_ROWS_EVENT, UPDATE_ROWS_EVENT, and DELETE_ROWS_EVENT type codes.
1042       The --base64-output=DECODE-ROWS and --verbose options may be used to
1043       affect row event output.
1044
1045       Suppose that the server is using row-based binary logging and that you
1046       execute the following sequence of statements:
1047
1048           CREATE TABLE t
1049           (
1050             id   INT NOT NULL,
1051             name VARCHAR(20) NOT NULL,
1052             date DATE NULL
1053           ) ENGINE = InnoDB;
1054           START TRANSACTION;
1055           INSERT INTO t VALUES(1, 'apple', NULL);
1056           UPDATE t SET name = 'pear', date = '2009-01-01' WHERE id = 1;
1057           DELETE FROM t WHERE id = 1;
1058           COMMIT;
1059
1060       By default, mysqlbinlog displays row events encoded as base-64 strings
1061       using BINLOG statements. Omitting extraneous lines, the output for the
1062       row events produced by the preceding statement sequence looks like
1063       this:
1064
1065           shell> mysqlbinlog log_file
1066           ...
1067           # at 218
1068           #080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
1069           BINLOG '
1070           fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1071           fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
1072           '/*!*/;
1073           ...
1074           # at 302
1075           #080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
1076           BINLOG '
1077           fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1078           fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
1079           '/*!*/;
1080           ...
1081           # at 400
1082           #080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
1083           BINLOG '
1084           fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1085           fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
1086           '/*!*/;
1087
1088       To see the row events as comments in the form of “pseudo-SQL”
1089       statements, run mysqlbinlog with the --verbose or -v option. This
1090       output level also shows table partition information where applicable.
1091       The output will contain lines beginning with ###:
1092
1093           shell> mysqlbinlog -v log_file
1094           ...
1095           # at 218
1096           #080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
1097           BINLOG '
1098           fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1099           fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
1100           '/*!*/;
1101           ### INSERT INTO test.t
1102           ### SET
1103           ###   @1=1
1104           ###   @2='apple'
1105           ###   @3=NULL
1106           ...
1107           # at 302
1108           #080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
1109           BINLOG '
1110           fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1111           fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
1112           '/*!*/;
1113           ### UPDATE test.t
1114           ### WHERE
1115           ###   @1=1
1116           ###   @2='apple'
1117           ###   @3=NULL
1118           ### SET
1119           ###   @1=1
1120           ###   @2='pear'
1121           ###   @3='2009:01:01'
1122           ...
1123           # at 400
1124           #080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
1125           BINLOG '
1126           fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1127           fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
1128           '/*!*/;
1129           ### DELETE FROM test.t
1130           ### WHERE
1131           ###   @1=1
1132           ###   @2='pear'
1133           ###   @3='2009:01:01'
1134
1135       Specify --verbose or -v twice to also display data types and some
1136       metadata for each column, and informational log events such as row
1137       query log events if the binlog_rows_query_log_events system variable is
1138       set to TRUE. The output will contain an additional comment following
1139       each column change:
1140
1141           shell> mysqlbinlog -vv log_file
1142           ...
1143           # at 218
1144           #080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
1145           BINLOG '
1146           fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1147           fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
1148           '/*!*/;
1149           ### INSERT INTO test.t
1150           ### SET
1151           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
1152           ###   @2='apple' /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
1153           ###   @3=NULL /* VARSTRING(20) meta=0 nullable=1 is_null=1 */
1154           ...
1155           # at 302
1156           #080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
1157           BINLOG '
1158           fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1159           fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
1160           '/*!*/;
1161           ### UPDATE test.t
1162           ### WHERE
1163           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
1164           ###   @2='apple' /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
1165           ###   @3=NULL /* VARSTRING(20) meta=0 nullable=1 is_null=1 */
1166           ### SET
1167           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
1168           ###   @2='pear' /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
1169           ###   @3='2009:01:01' /* DATE meta=0 nullable=1 is_null=0 */
1170           ...
1171           # at 400
1172           #080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
1173           BINLOG '
1174           fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
1175           fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
1176           '/*!*/;
1177           ### DELETE FROM test.t
1178           ### WHERE
1179           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
1180           ###   @2='pear' /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
1181           ###   @3='2009:01:01' /* DATE meta=0 nullable=1 is_null=0 */
1182
1183       You can tell mysqlbinlog to suppress the BINLOG statements for row
1184       events by using the --base64-output=DECODE-ROWS option. This is similar
1185       to --base64-output=NEVER but does not exit with an error if a row event
1186       is found. The combination of --base64-output=DECODE-ROWS and --verbose
1187       provides a convenient way to see row events only as SQL statements:
1188
1189           shell> mysqlbinlog -v --base64-output=DECODE-ROWS log_file
1190           ...
1191           # at 218
1192           #080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
1193           ### INSERT INTO test.t
1194           ### SET
1195           ###   @1=1
1196           ###   @2='apple'
1197           ###   @3=NULL
1198           ...
1199           # at 302
1200           #080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
1201           ### UPDATE test.t
1202           ### WHERE
1203           ###   @1=1
1204           ###   @2='apple'
1205           ###   @3=NULL
1206           ### SET
1207           ###   @1=1
1208           ###   @2='pear'
1209           ###   @3='2009:01:01'
1210           ...
1211           # at 400
1212           #080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
1213           ### DELETE FROM test.t
1214           ### WHERE
1215           ###   @1=1
1216           ###   @2='pear'
1217           ###   @3='2009:01:01'
1218
1219
1220           Note
1221           You should not suppress BINLOG statements if you intend to
1222           re-execute mysqlbinlog output.
1223
1224       The SQL statements produced by --verbose for row events are much more
1225       readable than the corresponding BINLOG statements. However, they do not
1226       correspond exactly to the original SQL statements that generated the
1227       events. The following limitations apply:
1228
1229       ·   The original column names are lost and replaced by @N, where N is a
1230           column number.
1231
1232       ·   Character set information is not available in the binary log, which
1233           affects string column display:
1234
1235           ·   There is no distinction made between corresponding binary and
1236               nonbinary string types (BINARY and CHAR, VARBINARY and VARCHAR,
1237               BLOB and TEXT). The output uses a data type of STRING for
1238               fixed-length strings and VARSTRING for variable-length strings.
1239
1240           ·   For multibyte character sets, the maximum number of bytes per
1241               character is not present in the binary log, so the length for
1242               string types is displayed in bytes rather than in characters.
1243               For example, STRING(4) will be used as the data type for values
1244               from either of these column types:
1245
1246                   CHAR(4) CHARACTER SET latin1
1247                   CHAR(2) CHARACTER SET ucs2
1248
1249           ·   Due to the storage format for events of type UPDATE_ROWS_EVENT,
1250               UPDATE statements are displayed with the WHERE clause preceding
1251               the SET clause.
1252
1253       Proper interpretation of row events requires the information from the
1254       format description event at the beginning of the binary log. Because
1255       mysqlbinlog does not know in advance whether the rest of the log
1256       contains row events, by default it displays the format description
1257       event using a BINLOG statement in the initial part of the output.
1258
1259       If the binary log is known not to contain any events requiring a BINLOG
1260       statement (that is, no row events), the --base64-output=NEVER option
1261       can be used to prevent this header from being written.
1262

USING MYSQLBINLOG TO BACK UP BINARY LOG FILES

1264       By default, mysqlbinlog reads binary log files and displays their
1265       contents in text format. This enables you to examine events within the
1266       files more easily and to re-execute them (for example, by using the
1267       output as input to mysql).  mysqlbinlog can read log files directly
1268       from the local file system, or, with the --read-from-remote-server
1269       option, it can connect to a server and request binary log contents from
1270       that server.  mysqlbinlog writes text output to its standard output, or
1271       to the file named as the value of the --result-file=file_name option if
1272       that option is given.
1273
1274       ·   mysqlbinlog Backup Capabilities
1275
1276       ·   mysqlbinlog Backup Options
1277
1278       ·   Static and Live Backups
1279
1280       ·   Output File Naming
1281
1282       ·   Example: mysqldump + mysqlbinlog for Backup and Restore
1283
1284       ·   mysqlbinlog Backup Restrictions
1285       mysqlbinlog Backup Capabilities
1286
1287       mysqlbinlog can read binary log files and write new files containing
1288       the same content—that is, in binary format rather than text format.
1289       This capability enables you to easily back up a binary log in its
1290       original format.  mysqlbinlog can make a static backup, backing up a
1291       set of log files and stopping when the end of the last file is reached.
1292       It can also make a continuous (“live”) backup, staying connected to the
1293       server when it reaches the end of the last log file and continuing to
1294       copy new events as they are generated. In continuous-backup operation,
1295       mysqlbinlog runs until the connection ends (for example, when the
1296       server exits) or mysqlbinlog is forcibly terminated. When the
1297       connection ends, mysqlbinlog does not wait and retry the connection,
1298       unlike a slave replication server. To continue a live backup after the
1299       server has been restarted, you must also restart mysqlbinlog.
1300
1301           Important
1302           mysqlbinlog can back up both encrypted and unencrypted binary log
1303           files . However, copies of encrypted binary log files that are
1304           generated using mysqlbinlog are stored in an unencrypted format.
1305       mysqlbinlog Backup Options
1306
1307       Binary log backup requires that you invoke mysqlbinlog with two options
1308       at minimum:
1309
1310       ·   The --read-from-remote-server (or -R) option tells mysqlbinlog to
1311           connect to a server and request its binary log. (This is similar to
1312           a slave replication server connecting to its master server.)
1313
1314       ·   The --raw option tells mysqlbinlog to write raw (binary) output,
1315           not text output.
1316
1317       Along with --read-from-remote-server, it is common to specify other
1318       options: --host indicates where the server is running, and you may also
1319       need to specify connection options such as --user and --password.
1320
1321       Several other options are useful in conjunction with --raw:
1322
1323       ·   --stop-never: Stay connected to the server after reaching the end
1324           of the last log file and continue to read new events.
1325
1326       ·   --connection-server-id=id: The server ID that mysqlbinlog reports
1327           when it connects to a server. When --stop-never is used, the
1328           default reported server ID is 1. If this causes a conflict with the
1329           ID of a slave server or another mysqlbinlog process, use
1330           --connection-server-id to specify an alternative server ID. See the
1331           section called “SPECIFYING THE MYSQLBINLOG SERVER ID”.
1332
1333       ·   --result-file: A prefix for output file names, as described later.
1334       Static and Live Backups
1335
1336       To back up a server's binary log files with mysqlbinlog, you must
1337       specify file names that actually exist on the server. If you do not
1338       know the names, connect to the server and use the SHOW BINARY LOGS
1339       statement to see the current names. Suppose that the statement produces
1340       this output:
1341
1342           mysql> SHOW BINARY LOGS;
1343           +---------------+-----------+-----------+
1344           | Log_name      | File_size | Encrypted |
1345           +---------------+-----------+-----------+
1346           | binlog.000130 |     27459 | No        |
1347           | binlog.000131 |     13719 | No        |
1348           | binlog.000132 |     43268 | No        |
1349           +---------------+-----------+-----------+
1350
1351       With that information, you can use mysqlbinlog to back up the binary
1352       log to the current directory as follows (enter each command on a single
1353       line):
1354
1355       ·   To make a static backup of binlog.000130 through binlog.000132, use
1356           either of these commands:
1357
1358               mysqlbinlog --read-from-remote-server --host=host_name --raw
1359                 binlog.000130 binlog.000131 binlog.000132
1360               mysqlbinlog --read-from-remote-server --host=host_name --raw
1361                 --to-last-log binlog.000130
1362
1363           The first command specifies every file name explicitly. The second
1364           names only the first file and uses --to-last-log to read through
1365           the last. A difference between these commands is that if the server
1366           happens to open binlog.000133 before mysqlbinlog reaches the end of
1367           binlog.000132, the first command will not read it, but the second
1368           command will.
1369
1370       ·   To make a live backup in which mysqlbinlog starts with
1371           binlog.000130 to copy existing log files, then stays connected to
1372           copy new events as the server generates them:
1373
1374               mysqlbinlog --read-from-remote-server --host=host_name --raw
1375                 --stop-never binlog.000130
1376
1377           With --stop-never, it is not necessary to specify --to-last-log to
1378           read to the last log file because that option is implied.
1379       Output File Naming
1380
1381       Without --raw, mysqlbinlog produces text output and the --result-file
1382       option, if given, specifies the name of the single file to which all
1383       output is written. With --raw, mysqlbinlog writes one binary output
1384       file for each log file transferred from the server. By default,
1385       mysqlbinlog writes the files in the current directory with the same
1386       names as the original log files. To modify the output file names, use
1387       the --result-file option. In conjunction with --raw, the --result-file
1388       option value is treated as a prefix that modifies the output file
1389       names.
1390
1391       Suppose that a server currently has binary log files named
1392       binlog.000999 and up. If you use mysqlbinlog --raw to back up the
1393       files, the --result-file option produces output file names as shown in
1394       the following table. You can write the files to a specific directory by
1395       beginning the --result-file value with the directory path. If the
1396       --result-file value consists only of a directory name, the value must
1397       end with the pathname separator character. Output files are overwritten
1398       if they exist.
1399
1400       ┌─────────────────────┬────────────────────────────┐
1401--result-file Option │ Output File Names          
1402       ├─────────────────────┼────────────────────────────┤
1403--result-file=x      │ xbinlog.000999 and up      │
1404       ├─────────────────────┼────────────────────────────┤
1405--result-file=/tmp/  │ /tmp/binlog.000999 and up  │
1406       ├─────────────────────┼────────────────────────────┤
1407--result-file=/tmp/x │ /tmp/xbinlog.000999 and up │
1408       └─────────────────────┴────────────────────────────┘
1409       Example: mysqldump + mysqlbinlog for Backup and Restore
1410
1411       The following example describes a simple scenario that shows how to use
1412       mysqldump and mysqlbinlog together to back up a server's data and
1413       binary log, and how to use the backup to restore the server if data
1414       loss occurs. The example assumes that the server is running on host
1415       host_name and its first binary log file is named binlog.000999. Enter
1416       each command on a single line.
1417
1418       Use mysqlbinlog to make a continuous backup of the binary log:
1419
1420           mysqlbinlog --read-from-remote-server --host=host_name --raw
1421             --stop-never binlog.000999
1422
1423       Use mysqldump to create a dump file as a snapshot of the server's data.
1424       Use --all-databases, --events, and --routines to back up all data, and
1425       --master-data=2 to include the current binary log coordinates in the
1426       dump file.
1427
1428           mysqldump --host=host_name --all-databases --events --routines --master-data=2> dump_file
1429
1430       Execute the mysqldump command periodically to create newer snapshots as
1431       desired.
1432
1433       If data loss occurs (for example, if the server crashes), use the most
1434       recent dump file to restore the data:
1435
1436           mysql --host=host_name -u root -p < dump_file
1437
1438       Then use the binary log backup to re-execute events that were written
1439       after the coordinates listed in the dump file. Suppose that the
1440       coordinates in the file look like this:
1441
1442           -- CHANGE MASTER TO MASTER_LOG_FILE='binlog.001002', MASTER_LOG_POS=27284;
1443
1444       If the most recent backed-up log file is named binlog.001004,
1445       re-execute the log events like this:
1446
1447           mysqlbinlog --start-position=27284 binlog.001002 binlog.001003 binlog.001004
1448             | mysql --host=host_name -u root -p
1449
1450       You might find it easier to copy the backup files (dump file and binary
1451       log files) to the server host to make it easier to perform the restore
1452       operation, or if MySQL does not allow remote root access.  mysqlbinlog
1453       Backup Restrictions
1454
1455       Binary log backups with mysqlbinlog are subject to these restrictions:
1456
1457       ·   mysqlbinlog does not automatically reconnect to the MySQL server if
1458           the connection is lost (for example, if a server restart occurs or
1459           there is a network outage).
1460
1461       ·   The delay for a backup is similar to the delay for a replication
1462           slave.
1463

SPECIFYING THE MYSQLBINLOG SERVER ID

1465       When invoked with the --read-from-remote-server option, mysqlbinlog
1466       connects to a MySQL server, specifies a server ID to identify itself,
1467       and requests binary log files from the server. You can use mysqlbinlog
1468       to request log files from a server in several ways:
1469
1470       ·   Specify an explicitly named set of files: For each file,
1471           mysqlbinlog connects and issues a Binlog dump command. The server
1472           sends the file and disconnects. There is one connection per file.
1473
1474       ·   Specify the beginning file and --to-last-log: mysqlbinlog connects
1475           and issues a Binlog dump command for all files. The server sends
1476           all files and disconnects.
1477
1478       ·   Specify the beginning file and --stop-never (which implies
1479           --to-last-log): mysqlbinlog connects and issues a Binlog dump
1480           command for all files. The server sends all files, but does not
1481           disconnect after sending the last one.
1482
1483       With --read-from-remote-server only, mysqlbinlog connects using a
1484       server ID of 0, which tells the server to disconnect after sending the
1485       last requested log file.
1486
1487       With --read-from-remote-server and --stop-never, mysqlbinlog connects
1488       using a nonzero server ID, so the server does not disconnect after
1489       sending the last log file. The server ID is 1 by default, but this can
1490       be changed with --connection-server-id.
1491
1492       Thus, for the first two ways of requesting files, the server
1493       disconnects because mysqlbinlog specifies a server ID of 0. It does not
1494       disconnect if --stop-never is given because mysqlbinlog specifies a
1495       nonzero server ID.
1496
1498       Copyright © 1997, 2020, Oracle and/or its affiliates. All rights
1499       reserved.
1500
1501       This documentation is free software; you can redistribute it and/or
1502       modify it only under the terms of the GNU General Public License as
1503       published by the Free Software Foundation; version 2 of the License.
1504
1505       This documentation is distributed in the hope that it will be useful,
1506       but WITHOUT ANY WARRANTY; without even the implied warranty of
1507       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1508       General Public License for more details.
1509
1510       You should have received a copy of the GNU General Public License along
1511       with the program; if not, write to the Free Software Foundation, Inc.,
1512       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
1513       http://www.gnu.org/licenses/.
1514
1515

NOTES

1517        1. MySQL Internals: The Binary Log
1518           https://dev.mysql.com/doc/internals/en/binary-log.html
1519

SEE ALSO

1521       For more information, please refer to the MySQL Reference Manual, which
1522       may already be installed locally and which is also available online at
1523       http://dev.mysql.com/doc/.
1524

AUTHOR

1526       Oracle Corporation (http://dev.mysql.com/).
1527
1528
1529
1530MySQL 8.0                         03/06/2020                    MYSQLBINLOG(1)
Impressum