1MYSQLBINLOG(1)              MariaDB 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.
18
19       Invoke mysqlbinlog like this:
20
21           shell> mysqlbinlog [options] log_file ...
22
23       For example, to display the contents of the binary log file named
24       binlog.000003, use this command:
25
26           shell> mysqlbinlog binlog.0000003
27
28       The output includes events contained in binlog.000003. For
29       statement-based logging, event information includes the SQL statement,
30       the ID of the server on which it was executed, the timestamp when the
31       statement was executed, how much time it took, and so forth. For
32       row-based logging, the event indicates a row change rather than an SQL
33       statement.
34
35       Events are preceded by header comments that provide additional
36       information. For example:
37
38           # at 141
39           #100309  9:28:36 server id 123  end_log_pos 245
40             Query thread_id=3350  exec_time=11  error_code=0
41
42       In the first line, the number following at indicates the starting
43       position of the event in the binary log file.
44
45       The second line starts with a date and time indicating when the
46       statement started on the server where the event originated. For
47       replication, this timestamp is propagated to slave servers.  server id
48       is the server_id value of the server where the event originated.
49       end_log_pos indicates where the next event starts (that is, it is the
50       end position of the current event + 1).  thread_id indicates which
51       thread executed the event.  exec_time is the time spent executing the
52       event, on a master server. On a slave, it is the difference of the end
53       execution time on the slave minus the beginning execution time on the
54       master. The difference serves as an indicator of how much replication
55       lags behind the master.  error_code indicates the result from executing
56       the event. Zero means that no error occurred.
57
58       The output from mysqlbinlog can be re-executed (for example, by using
59       it as input to mysql) to redo the statements in the log. This is useful
60       for recovery operations after a server crash. For other usage examples,
61       see the discussion later in this section.
62
63       Normally, you use mysqlbinlog to read binary log files directly and
64       apply them to the local MariaDB server. It is also possible to read
65       binary logs from a remote server by using the --read-from-remote-server
66       option. To read remote binary logs, the connection parameter options
67       can be given to indicate how to connect to the server. These options
68       are --host, --password, --port, --protocol, --socket, and --user; they
69       are ignored except when you also use the --read-from-remote-server
70       option.
71
72       mysqlbinlog supports the following options, which can be specified on
73       the command line or in the [mysqlbinlog] and [client] option file
74       groups.
75
76--help, -?
77
78           Display a help message and exit.
79
80--base64-output=value
81
82           This option determines when events should be displayed encoded as
83           base-64 strings using BINLOG statements. The option has these
84           allowable values (not case sensitive):
85
86           •   AUTO ("automatic") or UNSPEC ("unspecified") displays BINLOG
87               statements automatically when necessary (that is, for format
88               description events and row events). This is the default if no
89               --base64-output option is given.
90
91                   Note
92                   Automatic BINLOG display is the only safe behavior if you
93                   intend to use the output of mysqlbinlog to re-execute
94                   binary log file contents. The other option values are
95                   intended only for debugging or testing purposes because
96                   they may produce output that does not include all events in
97                   executable form.
98
99           •   NEVER causes BINLOG statements not to be displayed.
100               mysqlbinlog exits with an error if a row event is found that
101               must be displayed using BINLOG.
102
103           •   DECODE-ROWS specifies to mysqlbinlog that you intend for row
104               events to be decoded and displayed as commented SQL statements
105               by also specifying the --verbose option. Like NEVER,
106               DECODE-ROWS suppresses display of BINLOG statements, but unlike
107               NEVER, it does not exit with an error if a row event is found.
108               The --base64-output can be given as --base64-output or
109               --skip-base64-output (with the sense of AUTO or NEVER).
110
111               For examples that show the effect of --base64-output and
112               --verbose on row event output, see the section called
113               “MYSQLBINLOG ROW EVENT DISPLAY”.
114
115--binlog-row-event-max-size=path
116
117           The directory where character sets are installed.
118
119--character-sets-dir=path
120
121           The directory where character sets are installed.
122
123--database=db_name, -d db_name
124
125           This option causes mysqlbinlog to output entries from the binary
126           log (local log only) that occur while db_name has been selected as
127           the default database by USE.
128
129           The --database option for mysqlbinlog is similar to the
130           --binlog-do-db option for mysqld, but can be used to specify only
131           one database. If --database is given multiple times, only the last
132           instance is used.
133
134           The effects of this option depend on whether the statement-based or
135           row-based logging format is in use, in the same way that the
136           effects of --binlog-do-db depend on whether statement-based or
137           row-based logging is in use.
138
139           Statement-based logging. The --database option works as follows:
140
141           •   While db_name is the default database, statements are output
142               whether they modify tables in db_name or a different database.
143
144           •   Unless db_name is selected as the default database, statements
145               are not output, even if they modify tables in db_name.
146
147           •   There is an exception for CREATE DATABASE, ALTER DATABASE, and
148               DROP DATABASE. The database being created, altered, or dropped
149               is considered to be the default database when determining
150               whether to output the statement.
151               Suppose that the binary log was created by executing these
152               statements using statement-based-logging:
153
154                   INSERT INTO test.t1 (i) VALUES(100);
155                   INSERT INTO db2.t2 (j)  VALUES(200);
156                   USE test;
157                   INSERT INTO test.t1 (i) VALUES(101);
158                   INSERT INTO t1 (i)      VALUES(102);
159                   INSERT INTO db2.t2 (j)  VALUES(201);
160                   USE db2;
161                   INSERT INTO test.t1 (i) VALUES(103);
162                   INSERT INTO db2.t2 (j)  VALUES(202);
163                   INSERT INTO t2 (j)      VALUES(203);
164
165               mysqlbinlog --database=test does not output the first two
166               INSERT statements because there is no default database. It
167               outputs the three INSERT statements following USE test, but not
168               the three INSERT statements following USE db2.
169
170               mysqlbinlog --database=db2 does not output the first two INSERT
171               statements because there is no default database. It does not
172               output the three INSERT statements following USE test, but does
173               output the three INSERT statements following USE db2.
174
175               Row-based logging.  mysqlbinlog outputs only entries that
176               change tables belonging to db_name. The default database has no
177               effect on this. Suppose that the binary log just described was
178               created using row-based logging rather than statement-based
179               logging.  mysqlbinlog --database=test outputs only those
180               entries that modify t1 in the test database, regardless of
181               whether USE was issued or what the default database is.  If a
182               server is running with binlog_format set to MIXED and you want
183               it to be possible to use mysqlbinlog with the --database
184               option, you must ensure that tables that are modified are in
185               the database selected by USE. (In particular, no cross-database
186               updates should be used.)
187
188                   Note
189                   This option did not work correctly for mysqlbinlog with
190                   row-based logging prior to MySQL 5.1.37.
191
192--debug[=debug_options], -# [debug_options]
193
194           Write a debugging log. A typical debug_options string is
195           ´d:t:o,file_name´. The default is ´d:t:o,/tmp/mysqlbinlog.trace´.
196
197--debug-check
198
199           Print some debugging information when the program exits.
200
201--debug-info
202
203           Print debugging information and memory and CPU usage statistics
204           when the program exits.
205
206--defaults-extra-file=name
207
208           Read this file after the global files are read.
209
210--defaults-file=name
211
212           Only read default options from the given file.
213
214--default-auth=name
215
216           Default authentication client-side plugin to use.
217
218--disable-log-bin, -D
219
220           Disable binary logging. This is useful for avoiding an endless loop
221           if you use the --to-last-log option and are sending the output to
222           the same MariaDB server. This option also is useful when restoring
223           after a crash to avoid duplication of the statements you have
224           logged.
225
226           This option requires that you have the SUPER privilege. It causes
227           mysqlbinlog to include a SET sql_log_bin = 0 statement in its
228           output to disable binary logging of the remaining output. The SET
229           statement is ineffective unless you have the SUPER privilege.
230
231--force-if-open
232
233           Force if binlog was not closed properly. Defaults to on; use
234           --skip-force-if-open to disable.
235
236--force-read, -f
237
238           With this option, if mysqlbinlog reads a binary log event that it
239           does not recognize, it prints a warning, ignores the event, and
240           continues. Without this option, mysqlbinlog stops if it reads such
241           an event.
242
243--hexdump, -H
244
245           Display a hex dump of the log in comments, as described in the
246           section called “MYSQLBINLOG HEX DUMP FORMAT”. The hex output can be
247           helpful for replication debugging.
248
249--host=host_name, -h host_name
250
251           Get the binary log from the MariaDB server on the given host.
252
253--local-load=path, -l path
254
255           Prepare local temporary files for LOAD DATA INFILE in the specified
256           directory.
257
258--no-defaults
259
260           Don't read default options from any option file.
261
262--offset=N, -o N
263
264           Skip the first N entries in the log.
265
266--open-files-limit=NUM
267
268           Sets the open_files_limit variable, which is used to reserve file
269           descriptors for mysqlbinlog.
270
271--password[=password], -p[password]
272
273           The password to use when connecting to the server. If you use the
274           short option form (-p), you cannot have a space between the option
275           and the password. If you omit the password value following the
276           --password or -p option on the command line, mysqlbinlog prompts
277           for one.
278
279           Specifying a password on the command line should be considered
280           insecure. You can use an option file to avoid giving the password
281           on the command line.
282
283--plugin-dir=dir_name
284
285           Directory for client-side plugins.
286
287--print-defaults
288
289           Print the program argument list from all option files and exit.
290
291--port=port_num, -P port_num
292
293           The TCP/IP port number to use for connecting to a remote server, or
294           0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT,
295           /etc/services, built-in default (3306).
296
297--protocol={TCP|SOCKET|PIPE|MEMORY}
298
299           The connection protocol to use for connecting to the server. It is
300           useful when the other connection parameters normally would cause a
301           protocol to be used other than the one you want.
302
303--raw
304
305           Requires -R. Output raw binlog data instead of SQL statements.
306           Output files named after server logs.
307
308--read-from-remote-server, -R
309
310           Read the binary log from a MariaDB server rather than reading a
311           local log file. Any connection parameter options are ignored unless
312           this option is given as well. These options are --host, --password,
313           --port, --protocol, --socket, and --user.
314
315           This option requires that the remote server be running. It works
316           only for binary log files on the remote server, not relay log
317           files.
318
319--result-file=name, -r name
320
321           Direct output to the given file. With --raw this is a prefix for
322           the file names.
323
324--rewrite-db=name, -r name
325
326           Updates to a database with a different name than the original.
327           Example: rewrite-db='from->to'. For events that are binlogged as
328           statements, rewriting the database constitutes changing a
329           statement's default database from db1 to db2. There is no statement
330           analysis or rewrite of any kind, that is, if one specifies
331           "db1.tbl" in the statement explicitly, that occurrence won't be
332           changed to "db2.tbl". Row-based events are rewritten correctly to
333           use the new database name. Filtering (e.g. with --database=name)
334           happens after the database rewrites have been performed. If you use
335           this option on the command line and ">" has a special meaning to
336           your command interpreter, quote the value (e.g. --rewrite-
337           db="oldname->newname".
338
339--server-id=id
340
341           Display only those events created by the server having the given
342           server ID.
343
344--set-charset=charset_name
345
346           Add a SET NAMES charset_name statement to the output to specify the
347           character set to be used for processing log files.
348
349--short-form, -s
350
351           Display only the statements contained in the log, no extra info and
352           no row-based events. This is for testing only, and should not be
353           used in production systems. If you want to suppress base64-output,
354           consider using --base64-output=never instead.
355
356--socket=path, -S path
357
358           For connections to localhost, the Unix socket file to use, or, on
359           Windows, the name of the named pipe to use.
360
361--start-datetime=datetime
362
363           Start reading the binary log at the first event having a timestamp
364           equal to or later than the datetime argument. The datetime value is
365           relative to the local time zone on the machine where you run
366           mysqlbinlog. The value should be in a format accepted for the
367           DATETIME or TIMESTAMP data types. For example:
368
369               shell> mysqlbinlog --start-datetime="2014-12-25 11:25:56" binlog.000003
370
371           This option is useful for point-in-time recovery.
372
373--start-position=N, -j N
374
375           Start reading the binary log at the first event having a position
376           equal to or greater than N. This option applies to the first log
377           file named on the command line.
378
379           This option is useful for point-in-time recovery.
380
381--stop-datetime=datetime
382
383           Stop reading the binary log at the first event having a timestamp
384           equal to or later than the datetime argument. This option is useful
385           for point-in-time recovery. See the description of the
386           --start-datetime option for information about the datetime value.
387
388           This option is useful for point-in-time recovery.
389
390--stop-never
391
392           Wait for more data from the server instead of stopping at the end
393           of the last log. Implies --to-last-log.
394
395--stop-never-slave-server-id
396
397           The slave server_id used for --read-from-remote-server --stop-
398           never.
399
400--stop-position=N
401
402           Stop reading the binary log at the first event having a position
403           equal to or greater than N. This option applies to the last log
404           file named on the command line.
405
406           This option is useful for point-in-time recovery.
407
408--table, -T
409
410           List entries for just this table (local log only).
411
412--to-last-log, -t
413
414           Do not stop at the end of the requested binary log from a MariaDB
415           server, but rather continue printing until the end of the last
416           binary log. If you send the output to the same MariaDB server, this
417           may lead to an endless loop, so this option requires
418           --read-from-remote-server.
419
420--user=user_name, -u user_name
421
422           The MariaDB username to use when connecting to a remote server.
423
424--verbose, -v
425
426           Reconstruct row events and display them as commented SQL
427           statements. If this option is given twice, the output includes
428           comments to indicate column data types and some metadata.
429
430           For examples that show the effect of --base64-output and --verbose
431           on row event output, see the section called “MYSQLBINLOG ROW EVENT
432           DISPLAY”.
433
434--version, -V
435
436           Display version information and exit.
437
438       You can also set the following variable by using --var_name=value
439       syntax:
440
441       •   open_files_limit
442
443           Specify the number of open file descriptors to reserve.
444
445       You can pipe the output of mysqlbinlog into the mysql client to execute
446       the events contained in the binary log. This technique is used to
447       recover from a crash when you have an old backup. For example:
448
449           shell> mysqlbinlog binlog.000001 | mysql -u root -p
450
451       Or:
452
453           shell> mysqlbinlog binlog.[0-9]* | mysql -u root -p
454
455       You can also redirect the output of mysqlbinlog to a text file instead,
456       if you need to modify the statement log first (for example, to remove
457       statements that you do not want to execute for some reason). After
458       editing the file, execute the statements that it contains by using it
459       as input to the mysql program:
460
461           shell> mysqlbinlog binlog.000001 > tmpfile
462           shell> ... edit tmpfile ...
463           shell> mysql -u root -p < tmpfile
464
465       When mysqlbinlog is invoked with the --start-position option, it
466       displays only those events with an offset in the binary log greater
467       than or equal to a given position (the given position must match the
468       start of one event). It also has options to stop and start when it sees
469       an event with a given date and time. This enables you to perform
470       point-in-time recovery using the --stop-datetime option (to be able to
471       say, for example, “roll forward my databases to how they were today at
472       10:30 a.m.”).
473
474       If you have more than one binary log to execute on the MariaDB server,
475       the safe method is to process them all using a single connection to the
476       server. Here is an example that demonstrates what may be unsafe:
477
478           shell> mysqlbinlog binlog.000001 | mysql -u root -p # DANGER!!
479           shell> mysqlbinlog binlog.000002 | mysql -u root -p # DANGER!!
480
481       Processing binary logs this way using different connections to the
482       server causes problems if the first log file contains a CREATE
483       TEMPORARY TABLE statement and the second log contains a statement that
484       uses the temporary table. When the first mysql process terminates, the
485       server drops the temporary table. When the second mysql process
486       attempts to use the table, the server reports “unknown table.”
487
488       To avoid problems like this, use a single mysql process to execute the
489       contents of all binary logs that you want to process. Here is one way
490       to do so:
491
492           shell> mysqlbinlog binlog.000001 binlog.000002 | mysql -u root -p
493
494       Another approach is to write all the logs to a single file and then
495       process the file:
496
497           shell> mysqlbinlog binlog.000001 >  /tmp/statements.sql
498           shell> mysqlbinlog binlog.000002 >> /tmp/statements.sql
499           shell> mysql -u root -p -e "source /tmp/statements.sql"
500
501       mysqlbinlog can produce output that reproduces a LOAD DATA INFILE
502       operation without the original data file.  mysqlbinlog copies the data
503       to a temporary file and writes a LOAD DATA LOCAL INFILE statement that
504       refers to the file. The default location of the directory where these
505       files are written is system-specific. To specify a directory
506       explicitly, use the --local-load option.
507
508       Because mysqlbinlog converts LOAD DATA INFILE statements to LOAD DATA
509       LOCAL INFILE statements (that is, it adds LOCAL), both the client and
510       the server that you use to process the statements must be configured
511       with the LOCAL capability enabled.
512
513           Warning
514           The temporary files created for LOAD DATA LOCAL statements are not
515           automatically deleted because they are needed until you actually
516           execute those statements. You should delete the temporary files
517           yourself after you no longer need the statement log. The files can
518           be found in the temporary file directory and have names like
519           original_file_name-#-#.
520

MYSQLBINLOG HEX DUMP FORMAT

522       The --hexdump option causes mysqlbinlog to produce a hex dump of the
523       binary log contents:
524
525           shell> mysqlbinlog --hexdump master-bin.000001
526
527       The hex output consists of comment lines beginning with #, so the
528       output might look like this for the preceding command:
529
530           /*!40019 SET @@session.max_insert_delayed_threads=0*/;
531           /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
532           # at 4
533           #051024 17:24:13 server id 1  end_log_pos 98
534           # Position  Timestamp   Type   Master ID        Size      Master Pos    Flags
535           # 00000004 9d fc 5c 43   0f   01 00 00 00   5e 00 00 00   62 00 00 00   00 00
536           # 00000017 04 00 35 2e 30 2e 31 35  2d 64 65 62 75 67 2d 6c |..5.0.15.debug.l|
537           # 00000027 6f 67 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |og..............|
538           # 00000037 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
539           # 00000047 00 00 00 00 9d fc 5c 43  13 38 0d 00 08 00 12 00 |.......C.8......|
540           # 00000057 04 04 04 04 12 00 00 4b  00 04 1a                |.......K...|
541           #       Start: binlog v 4, server v 5.0.15-debug-log created 051024 17:24:13
542           #       at startup
543           ROLLBACK;
544
545       Hex dump output currently contains the elements in the following list.
546       This format is subject to change. (For more information about binary
547       log format, see
548       http://forge.mysql.com/wiki/MySQL_Internals_Binary_Log.)
549
550       •   Position: The byte position within the log file.
551
552       •   Timestamp: The event timestamp. In the example shown, ´9d fc 5c 43´
553           is the representation of ´051024 17:24:13´ in hexadecimal.
554
555       •   Type: The event type code. In the example shown, ´0f´ indicates a
556           FORMAT_DESCRIPTION_EVENT. The following table lists the possible
557           type codes.
558
559           ┌─────┬──────────────────────────┬─────────────────────────────────┐
560           │Type │ Name                     │ Meaning                         │
561           ├─────┼──────────────────────────┼─────────────────────────────────┤
562           │00   │ UNKNOWN_EVENT            │ This event should never be      │
563           │     │                          │ present in the log.             │
564           ├─────┼──────────────────────────┼─────────────────────────────────┤
565           │01   │ START_EVENT_V3           │ This indicates the start of a   │
566           │     │                          │ log file written by MySQL 4 or  │
567           │     │                          │ earlier.                        │
568           ├─────┼──────────────────────────┼─────────────────────────────────┤
569           │02   │ QUERY_EVENT              │ The most common type of events. │
570           │     │                          │ These contain statements        │
571           │     │                          │ executed on the master.         │
572           ├─────┼──────────────────────────┼─────────────────────────────────┤
573           │03   │ STOP_EVENT               │ Indicates that master has       │
574           │     │                          │ stopped.                        │
575           ├─────┼──────────────────────────┼─────────────────────────────────┤
576           │04   │ ROTATE_EVENT             │ Written when the master         │
577           │     │                          │ switches to a new log file.     │
578           ├─────┼──────────────────────────┼─────────────────────────────────┤
579           │05   │ INTVAR_EVENT             │ Used for AUTO_INCREMENT values  │
580           │     │                          │ or when the LAST_INSERT_ID()    │
581           │     │                          │ function is used in the         │
582           │     │                          │ statement.                      │
583           ├─────┼──────────────────────────┼─────────────────────────────────┤
584           │06   │ LOAD_EVENT               │ Used for LOAD DATA INFILE in    │
585           │     │                          │ MySQL 3.23.                     │
586           ├─────┼──────────────────────────┼─────────────────────────────────┤
587           │07   │ SLAVE_EVENT              │ Reserved for future use.        │
588           ├─────┼──────────────────────────┼─────────────────────────────────┤
589           │08   │ CREATE_FILE_EVENT        │ Used for LOAD DATA INFILE       │
590           │     │                          │ statements. This indicates the  │
591           │     │                          │ start of execution of such a    │
592           │     │                          │ statement. A temporary file is  │
593           │     │                          │ created on the slave. Used in   │
594           │     │                          │ MySQL 4 only.                   │
595           ├─────┼──────────────────────────┼─────────────────────────────────┤
596           │09   │ APPEND_BLOCK_EVENT       │ Contains data for use in a LOAD │
597           │     │                          │ DATA INFILE statement. The data │
598           │     │                          │ is stored in the temporary file │
599           │     │                          │ on the slave.                   │
600           ├─────┼──────────────────────────┼─────────────────────────────────┤
601           │0a   │ EXEC_LOAD_EVENT          │ Used for LOAD DATA INFILE       │
602           │     │                          │ statements. The contents of the │
603           │     │                          │ temporary file is stored in the │
604           │     │                          │ table on the slave.  Used in    │
605           │     │                          │ MySQL 4 only.                   │
606           ├─────┼──────────────────────────┼─────────────────────────────────┤
607           │0b   │ DELETE_FILE_EVENT        │ Rollback of a LOAD DATA INFILE  │
608           │     │                          │ statement. The temporary file   │
609           │     │                          │ should be deleted on the slave. │
610           ├─────┼──────────────────────────┼─────────────────────────────────┤
611           │0c   │ NEW_LOAD_EVENT           │ Used for LOAD DATA INFILE in    │
612           │     │                          │ MySQL 4 and earlier.            │
613           ├─────┼──────────────────────────┼─────────────────────────────────┤
614           │0d   │ RAND_EVENT               │ Used to send information about  │
615           │     │                          │ random values if the RAND()     │
616           │     │                          │ function is used in the         │
617           │     │                          │ statement.                      │
618           ├─────┼──────────────────────────┼─────────────────────────────────┤
619           │0e   │ USER_VAR_EVENT           │ Used to replicate user          │
620           │     │                          │ variables.                      │
621           ├─────┼──────────────────────────┼─────────────────────────────────┤
622           │0f   │ FORMAT_DESCRIPTION_EVENT │ This indicates the start of a   │
623           │     │                          │ log file written by MySQL 5 or  │
624           │     │                          │ later.                          │
625           ├─────┼──────────────────────────┼─────────────────────────────────┤
626           │10   │ XID_EVENT                │ Event indicating commit of an   │
627           │     │                          │ XA transaction.                 │
628           ├─────┼──────────────────────────┼─────────────────────────────────┤
629           │11   │ BEGIN_LOAD_QUERY_EVENT   │ Used for LOAD DATA INFILE       │
630           │     │                          │ statements in MySQL 5 and       │
631           │     │                          │ later.                          │
632           ├─────┼──────────────────────────┼─────────────────────────────────┤
633           │12   │ EXECUTE_LOAD_QUERY_EVENT │ Used for LOAD DATA INFILE       │
634           │     │                          │ statements in MySQL 5 and       │
635           │     │                          │ later.                          │
636           ├─────┼──────────────────────────┼─────────────────────────────────┤
637           │13   │ TABLE_MAP_EVENT          │ Information about a table       │
638           │     │                          │ definition. Used in MySQL 5.1.5 │
639           │     │                          │ and later.                      │
640           ├─────┼──────────────────────────┼─────────────────────────────────┤
641           │14   │ PRE_GA_WRITE_ROWS_EVENT  │ Row data for a single table     │
642           │     │                          │ that should be created. Used in │
643           │     │                          │ MySQL 5.1.5 to 5.1.17.          │
644           ├─────┼──────────────────────────┼─────────────────────────────────┤
645           │15   │ PRE_GA_UPDATE_ROWS_EVENT │ Row data for a single table     │
646           │     │                          │ that needs to be updated. Used  │
647           │     │                          │ in MySQL 5.1.5 to 5.1.17.       │
648           ├─────┼──────────────────────────┼─────────────────────────────────┤
649           │16   │ PRE_GA_DELETE_ROWS_EVENT │ Row data for a single table     │
650           │     │                          │ that should be deleted. Used in │
651           │     │                          │ MySQL 5.1.5 to 5.1.17.          │
652           ├─────┼──────────────────────────┼─────────────────────────────────┤
653           │17   │ WRITE_ROWS_EVENT         │ Row data for a single table     │
654           │     │                          │ that should be created. Used in │
655           │     │                          │ MySQL 5.1.18 and later.         │
656           ├─────┼──────────────────────────┼─────────────────────────────────┤
657           │18   │ UPDATE_ROWS_EVENT        │ Row data for a single table     │
658           │     │                          │ that needs to be updated. Used  │
659           │     │                          │ in MySQL 5.1.18 and later.      │
660           ├─────┼──────────────────────────┼─────────────────────────────────┤
661           │19   │ DELETE_ROWS_EVENT        │ Row data for a single table     │
662           │     │                          │ that should be deleted. Used in │
663           │     │                          │ MySQL 5.1.18 and later.         │
664           ├─────┼──────────────────────────┼─────────────────────────────────┤
665           │1a   │ INCIDENT_EVENT           │ Something out of the ordinary   │
666           │     │                          │ happened. Added in MySQL        │
667           │     │                          │ 5.1.18.                         │
668           └─────┴──────────────────────────┴─────────────────────────────────┘
669
670       •   Master ID: The server ID of the master that created the event.
671
672       •   Size: The size in bytes of the event.
673
674       •   Master Pos: The position of the next event in the original master
675           log file.
676
677       •   Flags: 16 flags. Currently, the following flags are used. The
678           others are reserved for future use.
679
680           ┌─────┬─────────────────────────────┬──────────────────────────────┐
681           │Flag │ Name                        │ Meaning                      │
682           ├─────┼─────────────────────────────┼──────────────────────────────┤
683           │01   │ LOG_EVENT_BINLOG_IN_USE_F   │ Log file correctly closed.   │
684           │     │                             │ (Used only in                │
685           │     │                             │ FORMAT_DESCRIPTION_EVENT.)   │
686           │     │                             │ If this flag is set (if the  │
687           │     │                             │ flags are, for example, ´01  │
688           │     │                             │ 00´) in a                    │
689           │     │                             │ FORMAT_DESCRIPTION_EVENT,    │
690           │     │                             │ the log file has not been    │
691           │     │                             │ properly closed. Most        │
692           │     │                             │ probably this is because of  │
693           │     │                             │ a master crash (for example, │
694           │     │                             │ due to power failure).       │
695           ├─────┼─────────────────────────────┼──────────────────────────────┤
696           │02   │                             │ Reserved for future use.     │
697           ├─────┼─────────────────────────────┼──────────────────────────────┤
698           │04   │ LOG_EVENT_THREAD_SPECIFIC_F │ Set if the event is          │
699           │     │                             │ dependent on the connection  │
700           │     │                             │ it was executed in (for      │
701           │     │                             │ example, ´04 00´), for       │
702           │     │                             │ example, if the event uses   │
703           │     │                             │ temporary tables.            │
704           ├─────┼─────────────────────────────┼──────────────────────────────┤
705           │08   │ LOG_EVENT_SUPPRESS_USE_F    │ Set in some circumstances    │
706           │     │                             │ when the event is not        │
707           │     │                             │ dependent on the default     │
708           │     │                             │ database.                    │
709           └─────┴─────────────────────────────┴──────────────────────────────┘
710

MYSQLBINLOG ROW EVENT DISPLAY

712       The following examples illustrate how mysqlbinlog displays row events
713       that specify data modifications. These correspond to events with the
714       WRITE_ROWS_EVENT, UPDATE_ROWS_EVENT, and DELETE_ROWS_EVENT type codes.
715       The --base64-output=DECODE-ROWS and --verbose options may be used to
716       affect row event output.
717
718       Suppose that the server is using row-based binary logging and that you
719       execute the following sequence of statements:
720
721           CREATE TABLE t
722           (
723             id   INT NOT NULL,
724             name VARCHAR(20) NOT NULL,
725             date DATE NULL
726           ) ENGINE = InnoDB;
727           START TRANSACTION;
728           INSERT INTO t VALUES(1, ´apple´, NULL);
729           UPDATE t SET name = ´pear´, date = ´2009-01-01´ WHERE id = 1;
730           DELETE FROM t WHERE id = 1;
731           COMMIT;
732
733       By default, mysqlbinlog displays row events encoded as base-64 strings
734       using BINLOG statements. Omitting extraneous lines, the output for the
735       row events produced by the preceding statement sequence looks like
736       this:
737
738           shell> mysqlbinlog log_file
739           ...
740           # at 218
741           #080828 15:03:08 server id 1  end_log_pos 258     Write_rows: table id 17 flags: STMT_END_F
742           BINLOG ´
743           fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
744           fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
745           ´/*!*/;
746           ...
747           # at 302
748           #080828 15:03:08 server id 1  end_log_pos 356     Update_rows: table id 17 flags: STMT_END_F
749           BINLOG ´
750           fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
751           fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
752           ´/*!*/;
753           ...
754           # at 400
755           #080828 15:03:08 server id 1  end_log_pos 442     Delete_rows: table id 17 flags: STMT_END_F
756           BINLOG ´
757           fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
758           fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
759           ´/*!*/;
760
761       To see the row events as comments in the form of “pseudo-SQL”
762       statements, run mysqlbinlog with the --verbose or -v option. The output
763       will contain lines beginning with ###:
764
765           shell> mysqlbinlog -v log_file
766           ...
767           # at 218
768           #080828 15:03:08 server id 1  end_log_pos 258     Write_rows: table id 17 flags: STMT_END_F
769           BINLOG ´
770           fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
771           fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
772           ´/*!*/;
773           ### INSERT INTO test.t
774           ### SET
775           ###   @1=1
776           ###   @2=´apple´
777           ###   @3=NULL
778           ...
779           # at 302
780           #080828 15:03:08 server id 1  end_log_pos 356     Update_rows: table id 17 flags: STMT_END_F
781           BINLOG ´
782           fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
783           fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
784           ´/*!*/;
785           ### UPDATE test.t
786           ### WHERE
787           ###   @1=1
788           ###   @2=´apple´
789           ###   @3=NULL
790           ### SET
791           ###   @1=1
792           ###   @2=´pear´
793           ###   @3=´2009:01:01´
794           ...
795           # at 400
796           #080828 15:03:08 server id 1  end_log_pos 442     Delete_rows: table id 17 flags: STMT_END_F
797           BINLOG ´
798           fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
799           fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
800           ´/*!*/;
801           ### DELETE FROM test.t
802           ### WHERE
803           ###   @1=1
804           ###   @2=´pear´
805           ###   @3=´2009:01:01´
806
807       Specify --verbose or -v twice to also display data types and some
808       metadata for each column. The output will contain an additional comment
809       following each column change:
810
811           shell> mysqlbinlog -vv log_file
812           ...
813           # at 218
814           #080828 15:03:08 server id 1  end_log_pos 258     Write_rows: table id 17 flags: STMT_END_F
815           BINLOG ´
816           fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
817           fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
818           ´/*!*/;
819           ### INSERT INTO test.t
820           ### SET
821           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
822           ###   @2=´apple´ /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
823           ###   @3=NULL /* VARSTRING(20) meta=0 nullable=1 is_null=1 */
824           ...
825           # at 302
826           #080828 15:03:08 server id 1  end_log_pos 356     Update_rows: table id 17 flags: STMT_END_F
827           BINLOG ´
828           fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
829           fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
830           ´/*!*/;
831           ### UPDATE test.t
832           ### WHERE
833           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
834           ###   @2=´apple´ /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
835           ###   @3=NULL /* VARSTRING(20) meta=0 nullable=1 is_null=1 */
836           ### SET
837           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
838           ###   @2=´pear´ /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
839           ###   @3=´2009:01:01´ /* DATE meta=0 nullable=1 is_null=0 */
840           ...
841           # at 400
842           #080828 15:03:08 server id 1  end_log_pos 442     Delete_rows: table id 17 flags: STMT_END_F
843           BINLOG ´
844           fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
845           fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
846           ´/*!*/;
847           ### DELETE FROM test.t
848           ### WHERE
849           ###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
850           ###   @2=´pear´ /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
851           ###   @3=´2009:01:01´ /* DATE meta=0 nullable=1 is_null=0 */
852
853       You can tell mysqlbinlog to suppress the BINLOG statements for row
854       events by using the --base64-output=DECODE-ROWS option. This is similar
855       to --base64-output=NEVER but does not exit with an error if a row event
856       is found. The combination of --base64-output=DECODE-ROWS and --verbose
857       provides a convenient way to see row events only as SQL statements:
858
859           shell> mysqlbinlog -v --base64-output=DECODE-ROWS log_file
860           ...
861           # at 218
862           #080828 15:03:08 server id 1  end_log_pos 258     Write_rows: table id 17 flags: STMT_END_F
863           ### INSERT INTO test.t
864           ### SET
865           ###   @1=1
866           ###   @2=´apple´
867           ###   @3=NULL
868           ...
869           # at 302
870           #080828 15:03:08 server id 1  end_log_pos 356     Update_rows: table id 17 flags: STMT_END_F
871           ### UPDATE test.t
872           ### WHERE
873           ###   @1=1
874           ###   @2=´apple´
875           ###   @3=NULL
876           ### SET
877           ###   @1=1
878           ###   @2=´pear´
879           ###   @3=´2009:01:01´
880           ...
881           # at 400
882           #080828 15:03:08 server id 1  end_log_pos 442     Delete_rows: table id 17 flags: STMT_END_F
883           ### DELETE FROM test.t
884           ### WHERE
885           ###   @1=1
886           ###   @2=´pear´
887           ###   @3=´2009:01:01´
888
889
890           Note
891           You should not suppress BINLOG statements if you intend to
892           re-execute mysqlbinlog output.
893
894       The SQL statements produced by --verbose for row events are much more
895       readable than the corresponding BINLOG statements. However, they do not
896       correspond exactly to the original SQL statements that generated the
897       events. The following limitations apply:
898
899       •   The original column names are lost and replaced by @N, where N is a
900           column number.
901
902       •   Character set information is not available in the binary log, which
903           affects string column display:
904
905           •   There is no distinction made between corresponding binary and
906               nonbinary string types (BINARY and CHAR, VARBINARY and VARCHAR,
907               BLOB and TEXT). The output uses a data type of STRING for
908               fixed-length strings and VARSTRING for variable-length strings.
909
910           •   For multi-byte character sets, the maximum number of bytes per
911               character is not present in the binary log, so the length for
912               string types is displayed in bytes rather than in characters.
913               For example, STRING(4) will be used as the data type for values
914               from either of these column types:
915
916                   CHAR(4) CHARACTER SET latin1
917                   CHAR(2) CHARACTER SET ucs2
918
919           •   Due to the storage format for events of type UPDATE_ROWS_EVENT,
920               UPDATE statements are displayed with the WHERE clause preceding
921               the SET clause.
922
923       Proper interpretation of row events requires the information from the
924       format description event at the beginning of the binary log. Because
925       mysqlbinlog does not know in advance whether the rest of the log
926       contains row events, by default it displays the format description
927       event using a BINLOG statement in the initial part of the output.
928
929       If the binary log is known not to contain any events requiring a BINLOG
930       statement (that is, no row events), the --base64-output=NEVER option
931       can be used to prevent this header from being written.
932
934       Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.,
935       2010-2021 MariaDB Foundation
936
937       This documentation is free software; you can redistribute it and/or
938       modify it only under the terms of the GNU General Public License as
939       published by the Free Software Foundation; version 2 of the License.
940
941       This documentation is distributed in the hope that it will be useful,
942       but WITHOUT ANY WARRANTY; without even the implied warranty of
943       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
944       General Public License for more details.
945
946       You should have received a copy of the GNU General Public License along
947       with the program; if not, write to the Free Software Foundation, Inc.,
948       51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA or see
949       http://www.gnu.org/licenses/.
950
951

NOTES

953        1. Bug#42941
954           http://bugs.mysql.com/bug.php?id=42941
955

SEE ALSO

957       For more information, please refer to the MariaDB Knowledge Base,
958       available online at https://mariadb.com/kb/
959

AUTHOR

961       MariaDB Foundation (http://www.mariadb.org/).
962
963
964
965MariaDB 10.5                     14 April 2021                  MYSQLBINLOG(1)
Impressum