~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

1 by James Page
Import upstream version 5.6.15
1
'\" t
2
.\"     Title: \fBmysqlbinlog\fR
3
.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
4
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
1.2.6 by Marc Deslauriers
Import upstream version 5.6.25
5
.\"      Date: 05/05/2015
1 by James Page
Import upstream version 5.6.15
6
.\"    Manual: MySQL Database System
7
.\"    Source: MySQL 5.6
8
.\"  Language: English
9
.\"
1.2.6 by Marc Deslauriers
Import upstream version 5.6.25
10
.TH "\FBMYSQLBINLOG\FR" "1" "05/05/2015" "MySQL 5\&.6" "MySQL Database System"
1 by James Page
Import upstream version 5.6.15
11
.\" -----------------------------------------------------------------
12
.\" * Define some portability stuff
13
.\" -----------------------------------------------------------------
14
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
.\" http://bugs.debian.org/507673
16
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
.ie \n(.g .ds Aq \(aq
19
.el       .ds Aq '
20
.\" -----------------------------------------------------------------
21
.\" * set default formatting
22
.\" -----------------------------------------------------------------
23
.\" disable hyphenation
24
.nh
25
.\" disable justification (adjust text to left margin only)
26
.ad l
27
.\" -----------------------------------------------------------------
28
.\" * MAIN CONTENT STARTS HERE *
29
.\" -----------------------------------------------------------------
30
.\" mysqlbinlog
31
.SH "NAME"
32
mysqlbinlog \- utility for processing binary log files
33
.SH "SYNOPSIS"
34
.HP \w'\fBmysqlbinlog\ [\fR\fBoptions\fR\fB]\ \fR\fB\fIlog_file\fR\fR\fB\ \&.\&.\&.\fR\ 'u
35
\fBmysqlbinlog [\fR\fBoptions\fR\fB] \fR\fB\fIlog_file\fR\fR\fB \&.\&.\&.\fR
36
.SH "DESCRIPTION"
37
.PP
38
The server\*(Aqs binary log consists of files containing
39
\(lqevents\(rq
40
that describe modifications to database contents\&. The server writes these files in binary format\&. To display their contents in text format, use the
41
\fBmysqlbinlog\fR
42
utility\&. You can also use
43
\fBmysqlbinlog\fR
44
to display the contents of relay log files written by a slave server in a replication setup because relay logs have the same format as binary logs\&. The binary log and relay log are discussed further in
45
Section\ \&5.2.4, \(lqThe Binary Log\(rq, and
1.2.4 by Robie Basak
Import upstream version 5.6.23
46
Section\ \&17.2.2, \(lqReplication Relay and Status Logs\(rq\&.
1 by James Page
Import upstream version 5.6.15
47
.PP
48
Invoke
49
\fBmysqlbinlog\fR
50
like this:
51
.sp
52
.if n \{\
53
.RS 4
54
.\}
55
.nf
56
shell> \fBmysqlbinlog [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIlog_file\fR\fR\fB \&.\&.\&.\fR
57
.fi
58
.if n \{\
59
.RE
60
.\}
61
.PP
62
For example, to display the contents of the binary log file named
63
binlog\&.000003, use this command:
64
.sp
65
.if n \{\
66
.RS 4
67
.\}
68
.nf
69
shell> \fBmysqlbinlog binlog\&.0000003\fR
70
.fi
71
.if n \{\
72
.RE
73
.\}
74
.PP
75
The output includes events contained in
76
binlog\&.000003\&. For statement\-based logging, event information includes the SQL statement, the ID of the server on which it was executed, the timestamp when the statement was executed, how much time it took, and so forth\&. For row\-based logging, the event indicates a row change rather than an SQL statement\&. See
1.2.4 by Robie Basak
Import upstream version 5.6.23
77
Section\ \&17.1.2, \(lqReplication Formats\(rq, for information about logging modes\&.
1 by James Page
Import upstream version 5.6.15
78
.PP
79
Events are preceded by header comments that provide additional information\&. For example:
80
.sp
81
.if n \{\
82
.RS 4
83
.\}
84
.nf
85
# at 141
86
#100309  9:28:36 server id 123  end_log_pos 245
87
  Query thread_id=3350  exec_time=11  error_code=0
88
.fi
89
.if n \{\
90
.RE
91
.\}
92
.PP
93
In the first line, the number following
94
at
1.2.4 by Robie Basak
Import upstream version 5.6.23
95
indicates the file offset, or starting position, of the event in the binary log file\&.
1 by James Page
Import upstream version 5.6.15
96
.PP
97
The second line starts with a date and time indicating when the statement started on the server where the event originated\&. For replication, this timestamp is propagated to slave servers\&.
98
server id
99
is the
100
server_id
101
value of the server where the event originated\&.
102
end_log_pos
103
indicates where the next event starts (that is, it is the end position of the current event + 1)\&.
104
thread_id
105
indicates which thread executed the event\&.
106
exec_time
107
is the time spent executing the event, on a master server\&. On a slave, it is the difference of the end execution time on the slave minus the beginning execution time on the master\&. The difference serves as an indicator of how much replication lags behind the master\&.
108
error_code
109
indicates the result from executing the event\&. Zero means that no error occurred\&.
1.2.4 by Robie Basak
Import upstream version 5.6.23
110
.if n \{\
111
.sp
112
.\}
113
.RS 4
114
.it 1 an-trap
115
.nr an-no-space-flag 1
116
.nr an-break-flag 1
117
.br
118
.ps +1
119
\fBNote\fR
120
.ps -1
121
.br
122
.PP
123
When using event groups, the file offsets of events may be grouped together and the comments of events may be grouped together\&. Do not mistake these grouped events for blank file offsets\&.
124
.sp .5v
125
.RE
1 by James Page
Import upstream version 5.6.15
126
.PP
127
The output from
128
\fBmysqlbinlog\fR
129
can be re\-executed (for example, by using it as input to
130
\fBmysql\fR) to redo the statements in the log\&. This is useful for recovery operations after a server crash\&. For other usage examples, see the discussion later in this section and in
131
Section\ \&7.5, \(lqPoint-in-Time (Incremental) Recovery Using the Binary Log\(rq\&.
132
.PP
133
Normally, you use
134
\fBmysqlbinlog\fR
135
to read binary log files directly and apply them to the local MySQL server\&. It is also possible to read binary logs from a remote server by using the
136
\fB\-\-read\-from\-remote\-server\fR
137
option\&. To read remote binary logs, the connection parameter options can be given to indicate how to connect to the server\&. These options are
138
\fB\-\-host\fR,
139
\fB\-\-password\fR,
140
\fB\-\-port\fR,
141
\fB\-\-protocol\fR,
142
\fB\-\-socket\fR, and
143
\fB\-\-user\fR; they are ignored except when you also use the
144
\fB\-\-read\-from\-remote\-server\fR
145
option\&.
146
.PP
1.2.4 by Robie Basak
Import upstream version 5.6.23
147
When running
148
\fBmysqlbinlog\fR
149
against a large binary log, be careful that the filesystem has enough space for the resulting files\&. To configure the directory that
150
\fBmysqlbinlog\fR
151
uses for temporary files, use the
152
TMPDIR
153
environment variable\&.
154
.PP
1 by James Page
Import upstream version 5.6.15
155
\fBmysqlbinlog\fR
156
supports the following options, which can be specified on the command line or in the
157
[mysqlbinlog]
158
and
159
[client]
1.2.4 by Robie Basak
Import upstream version 5.6.23
160
groups of an option file\&. For information about option files used by MySQL programs, see
161
Section\ \&4.2.6, \(lqUsing Option Files\(rq\&.
1 by James Page
Import upstream version 5.6.15
162
.sp
163
.RS 4
164
.ie n \{\
165
\h'-04'\(bu\h'+03'\c
166
.\}
167
.el \{\
168
.sp -1
169
.IP \(bu 2.3
170
.\}
1.2.1 by James Page
Import upstream version 5.6.16
171
.\" mysqlbinlog: help option
172
.\" help option: mysqlbinlog
173
\fB\-\-help\fR,
1 by James Page
Import upstream version 5.6.15
174
\fB\-?\fR
175
.sp
176
Display a help message and exit\&.
177
.RE
178
.sp
179
.RS 4
180
.ie n \{\
181
\h'-04'\(bu\h'+03'\c
182
.\}
183
.el \{\
184
.sp -1
185
.IP \(bu 2.3
186
.\}
1.2.1 by James Page
Import upstream version 5.6.16
187
.\" mysqlbinlog: base64-output option
188
.\" base64-output option: mysqlbinlog
189
\fB\-\-base64\-output=\fR\fB\fIvalue\fR\fR
1 by James Page
Import upstream version 5.6.15
190
.sp
191
This option determines when events should be displayed encoded as base\-64 strings using
192
BINLOG
193
statements\&. The option has these permissible values (not case sensitive):
194
.sp
195
.RS 4
196
.ie n \{\
197
\h'-04'\(bu\h'+03'\c
198
.\}
199
.el \{\
200
.sp -1
201
.IP \(bu 2.3
202
.\}
203
AUTO
204
("automatic") or
205
UNSPEC
206
("unspecified") displays
207
BINLOG
208
statements automatically when necessary (that is, for format description events and row events)\&. If no
209
\fB\-\-base64\-output\fR
210
option is given, the effect is the same as
211
\fB\-\-base64\-output=AUTO\fR\&.
212
.if n \{\
213
.sp
214
.\}
215
.RS 4
216
.it 1 an-trap
217
.nr an-no-space-flag 1
218
.nr an-break-flag 1
219
.br
220
.ps +1
221
\fBNote\fR
222
.ps -1
223
.br
224
Automatic
225
BINLOG
226
display is the only safe behavior if you intend to use the output of
227
\fBmysqlbinlog\fR
228
to re\-execute binary log file contents\&. The other option values are intended only for debugging or testing purposes because they may produce output that does not include all events in executable form\&.
229
.sp .5v
230
.RE
231
.RE
232
.sp
233
.RS 4
234
.ie n \{\
235
\h'-04'\(bu\h'+03'\c
236
.\}
237
.el \{\
238
.sp -1
239
.IP \(bu 2.3
240
.\}
241
NEVER
242
causes
243
BINLOG
244
statements not to be displayed\&.
245
\fBmysqlbinlog\fR
246
exits with an error if a row event is found that must be displayed using
247
BINLOG\&.
248
.RE
249
.sp
250
.RS 4
251
.ie n \{\
252
\h'-04'\(bu\h'+03'\c
253
.\}
254
.el \{\
255
.sp -1
256
.IP \(bu 2.3
257
.\}
258
DECODE\-ROWS
259
specifies to
260
\fBmysqlbinlog\fR
261
that you intend for row events to be decoded and displayed as commented SQL statements by also specifying the
262
\fB\-\-verbose\fR
263
option\&. Like
264
NEVER,
265
DECODE\-ROWS
266
suppresses display of
267
BINLOG
268
statements, but unlike
269
NEVER, it does not exit with an error if a row event is found\&.
270
.RE
271
.sp
272
For examples that show the effect of
273
\fB\-\-base64\-output\fR
274
and
275
\fB\-\-verbose\fR
276
on row event output, see
277
the section called \(lqMYSQLBINLOG ROW EVENT DISPLAY\(rq\&.
278
.RE
279
.sp
280
.RS 4
281
.ie n \{\
282
\h'-04'\(bu\h'+03'\c
283
.\}
284
.el \{\
285
.sp -1
286
.IP \(bu 2.3
287
.\}
1.2.1 by James Page
Import upstream version 5.6.16
288
.\" mysqlbinlog: bind-address option
289
.\" bind-address option: mysqlbinlog
290
\fB\-\-bind\-address=\fR\fB\fIip_address\fR\fR
1 by James Page
Import upstream version 5.6.15
291
.sp
1.2.4 by Robie Basak
Import upstream version 5.6.23
292
On a computer having multiple network interfaces, use this option to select which interface to use for connecting to the MySQL server\&.
1 by James Page
Import upstream version 5.6.15
293
.sp
294
This option is supported beginning with MySQL 5\&.6\&.1\&.
295
.RE
296
.sp
297
.RS 4
298
.ie n \{\
299
\h'-04'\(bu\h'+03'\c
300
.\}
301
.el \{\
302
.sp -1
303
.IP \(bu 2.3
304
.\}
1.2.1 by James Page
Import upstream version 5.6.16
305
.\" mysqlbinlog: binlog-row-event-max-size option
306
.\" binlog-row-event-max-size option: mysqlbinlog
307
\fB\-\-binlog\-row\-event\-max\-size=\fR\fB\fIN\fR\fR
1 by James Page
Import upstream version 5.6.15
308
.TS
309
allbox tab(:);
310
l l s s
1.2.4 by Robie Basak
Import upstream version 5.6.23
311
l l l s
1 by James Page
Import upstream version 5.6.15
312
^ l l s
313
^ l l s
314
^ l l s.
315
T{
316
\fBCommand\-Line Format\fR
317
T}:T{
318
\-\-binlog\-row\-event\-max\-size=#
319
T}
320
T{
1.2.4 by Robie Basak
Import upstream version 5.6.23
321
\fBPermitted Values\fR (64\-bit platforms)
322
T}:T{
1 by James Page
Import upstream version 5.6.15
323
\fBType\fR
324
T}:T{
325
numeric
326
T}
327
:T{
328
\fBDefault\fR
329
T}:T{
330
4294967040
331
T}
332
:T{
1.2.4 by Robie Basak
Import upstream version 5.6.23
333
\fBMin Value\fR
334
T}:T{
335
256
336
T}
337
:T{
338
\fBMax Value\fR
339
T}:T{
340
18446744073709547520
1 by James Page
Import upstream version 5.6.15
341
T}
342
.TE
343
.sp 1
344
Specify the maximum size of a row\-based binary log event, in bytes\&. Rows are grouped into events smaller than this size if possible\&. The value should be a multiple of 256\&. The default is 4GB\&.
345
.RE
346
.sp
347
.RS 4
348
.ie n \{\
349
\h'-04'\(bu\h'+03'\c
350
.\}
351
.el \{\
352
.sp -1
353
.IP \(bu 2.3
354
.\}
1.2.1 by James Page
Import upstream version 5.6.16
355
.\" mysqlbinlog: character-sets-dir option
356
.\" character-sets-dir option: mysqlbinlog
357
\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
1 by James Page
Import upstream version 5.6.15
358
.sp
359
The directory where character sets are installed\&. See
360
Section\ \&10.5, \(lqCharacter Set Configuration\(rq\&.
361
.RE
362
.sp
363
.RS 4
364
.ie n \{\
365
\h'-04'\(bu\h'+03'\c
366
.\}
367
.el \{\
368
.sp -1
369
.IP \(bu 2.3
370
.\}
1.2.4 by Robie Basak
Import upstream version 5.6.23
371
.\" mysqlbinlog: connection-server-id option
372
.\" connection-server-id option: mysqlbinlog
373
\fB\-\-connection\-server\-id=\fR\fB\fIserver_id\fR\fR
374
.sp
375
This option is used to test a MySQL server for support of the
376
BINLOG_DUMP_NON_BLOCK
377
connection flag, which was inadvertently removed in MySQL 5\&.6\&.5, and restored in MySQL 5\&.6\&.20 (Bug #18000079, Bug #71178)\&. It is not required for normal operation\&.
378
.sp
379
The effective default and minimum values for this option depend on whether
380
\fBmysqlbinlog\fR
381
is run in blocking mode or non\-blocking mode\&. When
382
\fBmysqlbinlog\fR
383
is run in blocking mode, the default (and minimum) value is 1; when run in non\-blocking mode, the default (and minimum) value is 0\&.
384
.sp
385
This option was added in MySQL 5\&.6\&.20\&.
386
.RE
387
.sp
388
.RS 4
389
.ie n \{\
390
\h'-04'\(bu\h'+03'\c
391
.\}
392
.el \{\
393
.sp -1
394
.IP \(bu 2.3
395
.\}
1.2.1 by James Page
Import upstream version 5.6.16
396
.\" mysqlbinlog: database option
397
.\" database option: mysqlbinlog
398
\fB\-\-database=\fR\fB\fIdb_name\fR\fR,
1 by James Page
Import upstream version 5.6.15
399
\fB\-d \fR\fB\fIdb_name\fR\fR
400
.sp
401
This option causes
402
\fBmysqlbinlog\fR
403
to output entries from the binary log (local log only) that occur while
404
\fIdb_name\fR
405
is been selected as the default database by
406
USE\&.
407
.sp
408
The
409
\fB\-\-database\fR
410
option for
411
\fBmysqlbinlog\fR
412
is similar to the
413
\fB\-\-binlog\-do\-db\fR
414
option for
415
\fBmysqld\fR, but can be used to specify only one database\&. If
416
\fB\-\-database\fR
417
is given multiple times, only the last instance is used\&.
418
.sp
419
The effects of this option depend on whether the statement\-based or row\-based logging format is in use, in the same way that the effects of
420
\fB\-\-binlog\-do\-db\fR
421
depend on whether statement\-based or row\-based logging is in use\&.
422
.PP
423
\fBStatement-based logging\fR. The
424
\fB\-\-database\fR
425
option works as follows:
426
.sp
427
.RS 4
428
.ie n \{\
429
\h'-04'\(bu\h'+03'\c
430
.\}
431
.el \{\
432
.sp -1
433
.IP \(bu 2.3
434
.\}
435
While
436
\fIdb_name\fR
437
is the default database, statements are output whether they modify tables in
438
\fIdb_name\fR
439
or a different database\&.
440
.RE
441
.sp
442
.RS 4
443
.ie n \{\
444
\h'-04'\(bu\h'+03'\c
445
.\}
446
.el \{\
447
.sp -1
448
.IP \(bu 2.3
449
.\}
450
Unless
451
\fIdb_name\fR
452
is selected as the default database, statements are not output, even if they modify tables in
453
\fIdb_name\fR\&.
454
.RE
455
.sp
456
.RS 4
457
.ie n \{\
458
\h'-04'\(bu\h'+03'\c
459
.\}
460
.el \{\
461
.sp -1
462
.IP \(bu 2.3
463
.\}
464
There is an exception for
465
CREATE DATABASE,
466
ALTER DATABASE, and
467
DROP DATABASE\&. The database being
468
\fIcreated, altered, or dropped\fR
469
is considered to be the default database when determining whether to output the statement\&.
470
.RE
471
.sp
472
Suppose that the binary log was created by executing these statements using statement\-based\-logging:
473
.sp
474
.if n \{\
475
.RS 4
476
.\}
477
.nf
478
INSERT INTO test\&.t1 (i) VALUES(100);
479
INSERT INTO db2\&.t2 (j)  VALUES(200);
480
USE test;
481
INSERT INTO test\&.t1 (i) VALUES(101);
482
INSERT INTO t1 (i)      VALUES(102);
483
INSERT INTO db2\&.t2 (j)  VALUES(201);
484
USE db2;
485
INSERT INTO test\&.t1 (i) VALUES(103);
486
INSERT INTO db2\&.t2 (j)  VALUES(202);
487
INSERT INTO t2 (j)      VALUES(203);
488
.fi
489
.if n \{\
490
.RE
491
.\}
492
.sp
493
\fBmysqlbinlog \-\-database=test\fR
494
does not output the first two
495
INSERT
496
statements because there is no default database\&. It outputs the three
497
INSERT
498
statements following
499
USE test, but not the three
500
INSERT
501
statements following
502
USE db2\&.
503
.sp
504
\fBmysqlbinlog \-\-database=db2\fR
505
does not output the first two
506
INSERT
507
statements because there is no default database\&. It does not output the three
508
INSERT
509
statements following
510
USE test, but does output the three
511
INSERT
512
statements following
513
USE db2\&.
514
.PP
1.2.1 by James Page
Import upstream version 5.6.16
515
\fBRow-based logging\fR. 
516
\fBmysqlbinlog\fR
1 by James Page
Import upstream version 5.6.15
517
outputs only entries that change tables belonging to
518
\fIdb_name\fR\&. The default database has no effect on this\&. Suppose that the binary log just described was created using row\-based logging rather than statement\-based logging\&.
519
\fBmysqlbinlog \-\-database=test\fR
520
outputs only those entries that modify
521
t1
522
in the test database, regardless of whether
523
USE
524
was issued or what the default database is\&.
525
If a server is running with
526
binlog_format
527
set to
528
MIXED
529
and you want it to be possible to use
530
\fBmysqlbinlog\fR
531
with the
532
\fB\-\-database\fR
533
option, you must ensure that tables that are modified are in the database selected by
534
USE\&. (In particular, no cross\-database updates should be used\&.)
535
.sp
536
Prior to MySQL 5\&.6\&.10, the
537
\fB\-\-database\fR
538
option did not work correctly with a log written by a GTID\-enabled MySQL server\&. (Bug #15912728)
539
.RE
540
.sp
541
.RS 4
542
.ie n \{\
543
\h'-04'\(bu\h'+03'\c
544
.\}
545
.el \{\
546
.sp -1
547
.IP \(bu 2.3
548
.\}
1.2.1 by James Page
Import upstream version 5.6.16
549
.\" mysqlbinlog: debug option
550
.\" debug option: mysqlbinlog
551
\fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,
1 by James Page
Import upstream version 5.6.15
552
\fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR
553
.sp
554
Write a debugging log\&. A typical
555
\fIdebug_options\fR
556
string is
1.2.2 by James Page
Import upstream version 5.6.17
557
d:t:o,\fIfile_name\fR\&. The default is
558
d:t:o,/tmp/mysqlbinlog\&.trace\&.
1 by James Page
Import upstream version 5.6.15
559
.RE
560
.sp
561
.RS 4
562
.ie n \{\
563
\h'-04'\(bu\h'+03'\c
564
.\}
565
.el \{\
566
.sp -1
567
.IP \(bu 2.3
568
.\}
1.2.1 by James Page
Import upstream version 5.6.16
569
.\" mysqlbinlog: debug-check option
570
.\" debug-check option: mysqlbinlog
571
\fB\-\-debug\-check\fR
1 by James Page
Import upstream version 5.6.15
572
.sp
573
Print some debugging information when the program exits\&.
574
.RE
575
.sp
576
.RS 4
577
.ie n \{\
578
\h'-04'\(bu\h'+03'\c
579
.\}
580
.el \{\
581
.sp -1
582
.IP \(bu 2.3
583
.\}
1.2.1 by James Page
Import upstream version 5.6.16
584
.\" mysqlbinlog: debug-info option
585
.\" debug-info option: mysqlbinlog
586
\fB\-\-debug\-info\fR
1 by James Page
Import upstream version 5.6.15
587
.sp
588
Print debugging information and memory and CPU usage statistics when the program exits\&.
589
.RE
590
.sp
591
.RS 4
592
.ie n \{\
593
\h'-04'\(bu\h'+03'\c
594
.\}
595
.el \{\
596
.sp -1
597
.IP \(bu 2.3
598
.\}
1.2.1 by James Page
Import upstream version 5.6.16
599
.\" mysqlbinlog: default-auth option
600
.\" default-auth option: mysqlbinlog
601
\fB\-\-default\-auth=\fR\fB\fIplugin\fR\fR
1 by James Page
Import upstream version 5.6.15
602
.sp
1.2.5 by Marc Deslauriers
Import upstream version 5.6.24
603
A hint about the client\-side authentication plugin to use\&. See
1 by James Page
Import upstream version 5.6.15
604
Section\ \&6.3.7, \(lqPluggable Authentication\(rq\&.
605
.sp
606
This option was added in MySQL 5\&.6\&.2\&.
607
.RE
608
.sp
609
.RS 4
610
.ie n \{\
611
\h'-04'\(bu\h'+03'\c
612
.\}
613
.el \{\
614
.sp -1
615
.IP \(bu 2.3
616
.\}
1.2.3 by James Page
Import upstream version 5.6.19
617
.\" mysqlbinlog: defaults-extra-file option
618
.\" defaults-extra-file option: mysqlbinlog
619
\fB\-\-defaults\-extra\-file=\fR\fB\fIfile_name\fR\fR
620
.sp
621
Read this option file after the global option file but (on Unix) before the user option file\&. If the file does not exist or is otherwise inaccessible, an error occurs\&.
622
\fIfile_name\fR
623
is interpreted relative to the current directory if given as a relative path name rather than a full path name\&.
624
.RE
625
.sp
626
.RS 4
627
.ie n \{\
628
\h'-04'\(bu\h'+03'\c
629
.\}
630
.el \{\
631
.sp -1
632
.IP \(bu 2.3
633
.\}
634
.\" mysqlbinlog: defaults-file option
635
.\" defaults-file option: mysqlbinlog
636
\fB\-\-defaults\-file=\fR\fB\fIfile_name\fR\fR
637
.sp
638
Use only the given option file\&. If the file does not exist or is otherwise inaccessible, an error occurs\&.
639
\fIfile_name\fR
640
is interpreted relative to the current directory if given as a relative path name rather than a full path name\&.
641
.RE
642
.sp
643
.RS 4
644
.ie n \{\
645
\h'-04'\(bu\h'+03'\c
646
.\}
647
.el \{\
648
.sp -1
649
.IP \(bu 2.3
650
.\}
651
.\" mysqlbinlog: defaults-group-suffix option
652
.\" defaults-group-suffix option: mysqlbinlog
653
\fB\-\-defaults\-group\-suffix=\fR\fB\fIstr\fR\fR
654
.sp
655
Read not only the usual option groups, but also groups with the usual names and a suffix of
656
\fIstr\fR\&. For example,
657
\fBmysqlbinlog\fR
658
normally reads the
659
[client]
660
and
661
[mysqlbinlog]
662
groups\&. If the
663
\fB\-\-defaults\-group\-suffix=_other\fR
664
option is given,
665
\fBmysqlbinlog\fR
666
also reads the
667
[client_other]
668
and
669
[mysqlbinlog_other]
670
groups\&.
671
.RE
672
.sp
673
.RS 4
674
.ie n \{\
675
\h'-04'\(bu\h'+03'\c
676
.\}
677
.el \{\
678
.sp -1
679
.IP \(bu 2.3
680
.\}
1.2.1 by James Page
Import upstream version 5.6.16
681
.\" mysqlbinlog: disable-log-bin option
682
.\" disable-log-bin option: mysqlbinlog
683
\fB\-\-disable\-log\-bin\fR,
1 by James Page
Import upstream version 5.6.15
684
\fB\-D\fR
685
.sp
686
Disable binary logging\&. This is useful for avoiding an endless loop if you use the
687
\fB\-\-to\-last\-log\fR
688
option and are sending the output to the same MySQL server\&. This option also is useful when restoring after a crash to avoid duplication of the statements you have logged\&.
689
.sp
690
This option requires that you have the
691
SUPER
692
privilege\&. It causes
693
\fBmysqlbinlog\fR
694
to include a
695
SET sql_log_bin = 0
696
statement in its output to disable binary logging of the remaining output\&. The
697
SET
698
statement is ineffective unless you have the
699
SUPER
700
privilege\&.
701
.RE
702
.sp
703
.RS 4
704
.ie n \{\
705
\h'-04'\(bu\h'+03'\c
706
.\}
707
.el \{\
708
.sp -1
709
.IP \(bu 2.3
710
.\}
1.2.1 by James Page
Import upstream version 5.6.16
711
.\" mysqlbinlog: exclude-gtids option
712
.\" exclude-gtids option: mysqlbinlog
713
\fB\-\-exclude\-gtids=\fR\fB\fIgtid_set\fR\fR
1 by James Page
Import upstream version 5.6.15
714
.sp
715
Do not display any of the groups listed in the
716
\fIgtid_set\fR\&. Added in MySQL 5\&.6\&.5\&.
717
.RE
718
.sp
719
.RS 4
720
.ie n \{\
721
\h'-04'\(bu\h'+03'\c
722
.\}
723
.el \{\
724
.sp -1
725
.IP \(bu 2.3
726
.\}
1.2.1 by James Page
Import upstream version 5.6.16
727
.\" mysqlbinlog: force-if-open option
728
.\" force-if-open option: mysqlbinlog
729
\fB\-\-force\-if\-open\fR,
1 by James Page
Import upstream version 5.6.15
730
\fB\-F\fR
731
.sp
732
Read binary log files even if they are open or were not closed properly\&.
733
.RE
734
.sp
735
.RS 4
736
.ie n \{\
737
\h'-04'\(bu\h'+03'\c
738
.\}
739
.el \{\
740
.sp -1
741
.IP \(bu 2.3
742
.\}
1.2.1 by James Page
Import upstream version 5.6.16
743
.\" mysqlbinlog: force-read option
744
.\" force-read option: mysqlbinlog
745
\fB\-\-force\-read\fR,
1 by James Page
Import upstream version 5.6.15
746
\fB\-f\fR
747
.sp
748
With this option, if
749
\fBmysqlbinlog\fR
750
reads a binary log event that it does not recognize, it prints a warning, ignores the event, and continues\&. Without this option,
751
\fBmysqlbinlog\fR
752
stops if it reads such an event\&.
753
.RE
754
.sp
755
.RS 4
756
.ie n \{\
757
\h'-04'\(bu\h'+03'\c
758
.\}
759
.el \{\
760
.sp -1
761
.IP \(bu 2.3
762
.\}
1.2.1 by James Page
Import upstream version 5.6.16
763
.\" mysqlbinlog: hexdump option
764
.\" hexdump option: mysqlbinlog
765
\fB\-\-hexdump\fR,
1 by James Page
Import upstream version 5.6.15
766
\fB\-H\fR
767
.sp
768
Display a hex dump of the log in comments, as described in
769
the section called \(lqMYSQLBINLOG HEX DUMP FORMAT\(rq\&. The hex output can be helpful for replication debugging\&.
770
.RE
771
.sp
772
.RS 4
773
.ie n \{\
774
\h'-04'\(bu\h'+03'\c
775
.\}
776
.el \{\
777
.sp -1
778
.IP \(bu 2.3
779
.\}
1.2.1 by James Page
Import upstream version 5.6.16
780
.\" mysqlbinlog: host option
781
.\" host option: mysqlbinlog
782
\fB\-\-host=\fR\fB\fIhost_name\fR\fR,
1 by James Page
Import upstream version 5.6.15
783
\fB\-h \fR\fB\fIhost_name\fR\fR
784
.sp
785
Get the binary log from the MySQL server on the given host\&.
786
.RE
787
.sp
788
.RS 4
789
.ie n \{\
790
\h'-04'\(bu\h'+03'\c
791
.\}
792
.el \{\
793
.sp -1
794
.IP \(bu 2.3
795
.\}
1.2.1 by James Page
Import upstream version 5.6.16
796
.\" mysqlbinlog: include-gtids option
797
.\" include-gtids option: mysqlbinlog
798
\fB\-\-include\-gtids=\fR\fB\fIgtid_set\fR\fR
1 by James Page
Import upstream version 5.6.15
799
.sp
800
Display only the groups listed in the
801
\fIgtid_set\fR\&. Added in MySQL 5\&.6\&.5\&.
802
.RE
803
.sp
804
.RS 4
805
.ie n \{\
806
\h'-04'\(bu\h'+03'\c
807
.\}
808
.el \{\
809
.sp -1
810
.IP \(bu 2.3
811
.\}
1.2.1 by James Page
Import upstream version 5.6.16
812
.\" mysqlbinlog: local-load option
813
.\" local-load option: mysqlbinlog
814
\fB\-\-local\-load=\fR\fB\fIpath\fR\fR,
1 by James Page
Import upstream version 5.6.15
815
\fB\-l \fR\fB\fIpath\fR\fR
816
.sp
817
Prepare local temporary files for
818
LOAD DATA INFILE
819
in the specified directory\&.
820
.if n \{\
821
.sp
822
.\}
823
.RS 4
824
.it 1 an-trap
825
.nr an-no-space-flag 1
826
.nr an-break-flag 1
827
.br
828
.ps +1
829
\fBImportant\fR
830
.ps -1
831
.br
832
These temporary files are not automatically removed by
833
\fBmysqlbinlog\fR
834
or any other MySQL program\&.
835
.sp .5v
836
.RE
837
.RE
838
.sp
839
.RS 4
840
.ie n \{\
841
\h'-04'\(bu\h'+03'\c
842
.\}
843
.el \{\
844
.sp -1
845
.IP \(bu 2.3
846
.\}
1.2.2 by James Page
Import upstream version 5.6.17
847
.\" mysqlbinlog: login-path option
848
.\" login-path option: mysqlbinlog
849
\fB\-\-login\-path=\fR\fB\fIname\fR\fR
850
.sp
851
Read options from the named login path in the
852
\&.mylogin\&.cnf
1.2.6 by Marc Deslauriers
Import upstream version 5.6.25
853
login path file\&. A
1.2.2 by James Page
Import upstream version 5.6.17
854
\(lqlogin path\(rq
855
is an option group that permits only a limited set of options:
856
\fBhost\fR,
857
\fBuser\fR, and
1.2.4 by Robie Basak
Import upstream version 5.6.23
858
\fBpassword\fR\&. Think of a login path as a set of values that indicate the server host and the credentials for authenticating with the server\&. To create the login path file, use the
1.2.2 by James Page
Import upstream version 5.6.17
859
\fBmysql_config_editor\fR
860
utility\&. See
861
\fBmysql_config_editor\fR(1)\&. This option was added in MySQL 5\&.6\&.6\&.
862
.RE
863
.sp
864
.RS 4
865
.ie n \{\
866
\h'-04'\(bu\h'+03'\c
867
.\}
868
.el \{\
869
.sp -1
870
.IP \(bu 2.3
871
.\}
1.2.3 by James Page
Import upstream version 5.6.19
872
.\" mysqlbinlog: no-defaults option
873
.\" no-defaults option: mysqlbinlog
874
\fB\-\-no\-defaults\fR
875
.sp
876
Do not read any option files\&. If program startup fails due to reading unknown options from an option file,
877
\fB\-\-no\-defaults\fR
878
can be used to prevent them from being read\&.
879
.sp
880
The exception is that the
881
\&.mylogin\&.cnf
882
file, if it exists, is read in all cases\&. This permits passwords to be specified in a safer way than on the command line even when
883
\fB\-\-no\-defaults\fR
884
is used\&. (\&.mylogin\&.cnf
885
is created by the
886
\fBmysql_config_editor\fR
887
utility\&. See
888
\fBmysql_config_editor\fR(1)\&.)
889
.RE
890
.sp
891
.RS 4
892
.ie n \{\
893
\h'-04'\(bu\h'+03'\c
894
.\}
895
.el \{\
896
.sp -1
897
.IP \(bu 2.3
898
.\}
1.2.1 by James Page
Import upstream version 5.6.16
899
.\" mysqlbinlog: offset option
900
.\" offset option: mysqlbinlog
901
\fB\-\-offset=\fR\fB\fIN\fR\fR,
1 by James Page
Import upstream version 5.6.15
902
\fB\-o \fR\fB\fIN\fR\fR
903
.sp
904
Skip the first
905
\fIN\fR
906
entries in the log\&.
907
.RE
908
.sp
909
.RS 4
910
.ie n \{\
911
\h'-04'\(bu\h'+03'\c
912
.\}
913
.el \{\
914
.sp -1
915
.IP \(bu 2.3
916
.\}
1.2.1 by James Page
Import upstream version 5.6.16
917
.\" mysqlbinlog: password option
918
.\" password option: mysqlbinlog
919
\fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
1 by James Page
Import upstream version 5.6.15
920
\fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR
921
.sp
922
The password to use when connecting to the server\&. If you use the short option form (\fB\-p\fR), you
923
\fIcannot\fR
924
have a space between the option and the password\&. If you omit the
925
\fIpassword\fR
926
value following the
927
\fB\-\-password\fR
928
or
929
\fB\-p\fR
930
option on the command line,
931
\fBmysqlbinlog\fR
932
prompts for one\&.
933
.sp
934
Specifying a password on the command line should be considered insecure\&. See
935
Section\ \&6.1.2.1, \(lqEnd-User Guidelines for Password Security\(rq\&. You can use an option file to avoid giving the password on the command line\&.
936
.RE
937
.sp
938
.RS 4
939
.ie n \{\
940
\h'-04'\(bu\h'+03'\c
941
.\}
942
.el \{\
943
.sp -1
944
.IP \(bu 2.3
945
.\}
1.2.1 by James Page
Import upstream version 5.6.16
946
.\" mysqlbinlog: plugin-dir option
947
.\" plugin-dir option: mysqlbinlog
948
\fB\-\-plugin\-dir=\fR\fB\fIpath\fR\fR
1 by James Page
Import upstream version 5.6.15
949
.sp
950
The directory in which to look for plugins\&. It may be necessary to specify this option if the
951
\fB\-\-default\-auth\fR
952
option is used to specify an authentication plugin but
953
\fBmysqlbinlog\fR
954
does not find it\&. See
955
Section\ \&6.3.7, \(lqPluggable Authentication\(rq\&.
956
.sp
957
This option was added in MySQL 5\&.6\&.2\&.
958
.RE
959
.sp
960
.RS 4
961
.ie n \{\
962
\h'-04'\(bu\h'+03'\c
963
.\}
964
.el \{\
965
.sp -1
966
.IP \(bu 2.3
967
.\}
1.2.1 by James Page
Import upstream version 5.6.16
968
.\" mysqlbinlog: port option
969
.\" port option: mysqlbinlog
970
.\" TCP/IP
971
.\" ports
972
\fB\-\-port=\fR\fB\fIport_num\fR\fR,
1 by James Page
Import upstream version 5.6.15
973
\fB\-P \fR\fB\fIport_num\fR\fR
974
.sp
975
The TCP/IP port number to use for connecting to a remote server\&.
976
.RE
977
.sp
978
.RS 4
979
.ie n \{\
980
\h'-04'\(bu\h'+03'\c
981
.\}
982
.el \{\
983
.sp -1
984
.IP \(bu 2.3
985
.\}
1.2.3 by James Page
Import upstream version 5.6.19
986
.\" mysqlbinlog: print-defaults option
987
.\" print-defaults option: mysqlbinlog
988
\fB\-\-print\-defaults\fR
989
.sp
990
Print the program name and all options that it gets from option files\&.
991
.RE
992
.sp
993
.RS 4
994
.ie n \{\
995
\h'-04'\(bu\h'+03'\c
996
.\}
997
.el \{\
998
.sp -1
999
.IP \(bu 2.3
1000
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1001
.\" mysqlbinlog: protocol option
1002
.\" protocol option: mysqlbinlog
1003
\fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
1 by James Page
Import upstream version 5.6.15
1004
.sp
1005
The connection protocol to use for connecting to the server\&. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want\&. For details on the permissible values, see
1006
Section\ \&4.2.2, \(lqConnecting to the MySQL Server\(rq\&.
1007
.RE
1008
.sp
1009
.RS 4
1010
.ie n \{\
1011
\h'-04'\(bu\h'+03'\c
1012
.\}
1013
.el \{\
1014
.sp -1
1015
.IP \(bu 2.3
1016
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1017
.\" mysqlbinlog: raw option
1018
.\" raw option: mysqlbinlog
1019
\fB\-\-raw\fR
1 by James Page
Import upstream version 5.6.15
1020
.sp
1021
By default,
1022
\fBmysqlbinlog\fR
1023
reads binary log files and writes events in text format\&. The
1024
\fB\-\-raw\fR
1025
option tells
1026
\fBmysqlbinlog\fR
1027
to write them in their original binary format\&. Its use requires that
1028
\fB\-\-read\-from\-remote\-server\fR
1029
also be used because the files are requested from a server\&.
1030
\fBmysqlbinlog\fR
1031
writes one output file for each file read from the server\&. The
1032
\fB\-\-raw\fR
1033
option can be used to make a backup of a server\*(Aqs binary log\&. With the
1034
\fB\-\-stop\-never\fR
1035
option, the backup is
1036
\(lqlive\(rq
1037
because
1038
\fBmysqlbinlog\fR
1039
stays connected to the server\&. By default, output files are written in the current directory with the same names as the original log files\&. Output file names can be modified using the
1040
\fB\-\-result\-file\fR
1041
option\&. For more information, see
1042
the section called \(lqUSING MYSQLBINLOG TO BACK UP BINARY LOG FILES\(rq\&.
1043
.sp
1044
This option was added in MySQL 5\&.6\&.0\&.
1045
.RE
1046
.sp
1047
.RS 4
1048
.ie n \{\
1049
\h'-04'\(bu\h'+03'\c
1050
.\}
1051
.el \{\
1052
.sp -1
1053
.IP \(bu 2.3
1054
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1055
.\" mysqlbinlog: read-from-remote-master option
1056
.\" read-from-remote-master option: mysqlbinlog
1057
\fB\-\-read\-from\-remote\-master=\fR\fB\fItype\fR\fR
1 by James Page
Import upstream version 5.6.15
1058
.sp
1059
Read binary logs from a MySQL server with the
1060
COM_BINLOG_DUMP
1061
or
1062
COM_BINLOG_DUMP_GTID
1063
commands by setting the option value to either
1064
BINLOG\-DUMP\-NON\-GTIDS
1065
or
1066
BINLOG\-DUMP\-GTIDS, respectively\&. If
1067
\fB\-\-read\-from\-remote\-master=BINLOG\-DUMP\-GTIDS\fR
1068
is combined with
1069
\fB\-\-exclude\-gtids\fR, transactions can be filtered out on the master, avoiding unnecessary network traffic\&.
1070
.sp
1071
See also the description for
1072
\fB\-\-read\-from\-remote\-server\fR\&.
1073
.sp
1074
This option was added in MySQL 5\&.6\&.5\&.
1075
.RE
1076
.sp
1077
.RS 4
1078
.ie n \{\
1079
\h'-04'\(bu\h'+03'\c
1080
.\}
1081
.el \{\
1082
.sp -1
1083
.IP \(bu 2.3
1084
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1085
.\" mysqlbinlog: read-from-remote-server option
1086
.\" read-from-remote-server option: mysqlbinlog
1087
\fB\-\-read\-from\-remote\-server\fR,
1 by James Page
Import upstream version 5.6.15
1088
\fB\-R\fR
1089
.sp
1090
Read the binary log from a MySQL server rather than reading a local log file\&. Any connection parameter options are ignored unless this option is given as well\&. These options are
1091
\fB\-\-host\fR,
1092
\fB\-\-password\fR,
1093
\fB\-\-port\fR,
1094
\fB\-\-protocol\fR,
1095
\fB\-\-socket\fR, and
1096
\fB\-\-user\fR\&.
1097
.sp
1098
This option requires that the remote server be running\&. It works only for binary log files on the remote server, not relay log files\&.
1099
.sp
1100
As of MySQL 5\&.6\&.5, this option is like
1101
\fB\-\-read\-from\-remote\-master=BINLOG\-DUMP\-NON\-GTIDS\fR\&.
1102
.RE
1103
.sp
1104
.RS 4
1105
.ie n \{\
1106
\h'-04'\(bu\h'+03'\c
1107
.\}
1108
.el \{\
1109
.sp -1
1110
.IP \(bu 2.3
1111
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1112
.\" mysqlbinlog: result-file option
1113
.\" result-file option: mysqlbinlog
1114
\fB\-\-result\-file=\fR\fB\fIname\fR\fR,
1 by James Page
Import upstream version 5.6.15
1115
\fB\-r \fR\fB\fIname\fR\fR
1116
.sp
1117
Without the
1118
\fB\-\-raw\fR
1119
option, this option indicates the file to which
1120
\fBmysqlbinlog\fR
1121
writes text output\&. With
1122
\fB\-\-raw\fR,
1123
\fBmysqlbinlog\fR
1124
writes one binary output file for each log file transferred from the server, writing them by default in the current directory using the same names as the original log file\&. In this case, the
1125
\fB\-\-result\-file\fR
1126
option value is treated as a prefix that modifies output file names\&.
1127
.RE
1128
.sp
1129
.RS 4
1130
.ie n \{\
1131
\h'-04'\(bu\h'+03'\c
1132
.\}
1133
.el \{\
1134
.sp -1
1135
.IP \(bu 2.3
1136
.\}
1.2.2 by James Page
Import upstream version 5.6.17
1137
.\" mysqlbinlog: secure-auth option
1138
.\" secure-auth option: mysqlbinlog
1139
\fB\-\-secure\-auth\fR
1140
.sp
1141
Do not send passwords to the server in old (pre\-4\&.1) format\&. This prevents connections except for servers that use the newer password format\&. This option is enabled by default; use
1142
\fB\-\-skip\-secure\-auth\fR
1143
to disable it\&. This option was added in MySQL 5\&.6\&.17\&.
1144
.if n \{\
1145
.sp
1146
.\}
1147
.RS 4
1148
.it 1 an-trap
1149
.nr an-no-space-flag 1
1150
.nr an-break-flag 1
1151
.br
1152
.ps +1
1153
\fBNote\fR
1154
.ps -1
1155
.br
1156
Passwords that use the pre\-4\&.1 hashing method are less secure than passwords that use the native password hashing method and should be avoided\&. Pre\-4\&.1 passwords are deprecated and support for them will be removed in a future MySQL release\&. For account upgrade instructions, see
1157
Section\ \&6.3.8.3, \(lqMigrating Away from Pre-4.1 Password Hashing and the mysql_old_password Plugin\(rq\&.
1158
.sp .5v
1159
.RE
1160
.RE
1161
.sp
1162
.RS 4
1163
.ie n \{\
1164
\h'-04'\(bu\h'+03'\c
1165
.\}
1166
.el \{\
1167
.sp -1
1168
.IP \(bu 2.3
1169
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1170
.\" mysqlbinlog: server-id option
1171
.\" server-id option: mysqlbinlog
1172
\fB\-\-server\-id=\fR\fB\fIid\fR\fR
1 by James Page
Import upstream version 5.6.15
1173
.sp
1174
Display only those events created by the server having the given server ID\&.
1175
.RE
1176
.sp
1177
.RS 4
1178
.ie n \{\
1179
\h'-04'\(bu\h'+03'\c
1180
.\}
1181
.el \{\
1182
.sp -1
1183
.IP \(bu 2.3
1184
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1185
.\" mysqlbinlog: server-id-bits option
1186
.\" server-id-bits option: mysqlbinlog
1187
\fB\-\-server\-id\-bits=\fR\fB\fIN\fR\fR
1 by James Page
Import upstream version 5.6.15
1188
.sp
1189
Use only the first
1190
\fIN\fR
1191
bits of the
1192
server_id
1193
to identify the server\&. If the binary log was written by a
1194
\fBmysqld\fR
1195
with server\-id\-bits set to less than 32 and user data stored in the most significant bit, running
1196
\fBmysqlbinlog\fR
1197
with
1198
\fB\-\-server\-id\-bits\fR
1199
set to 32 enables this data to be seen\&.
1200
.sp
1201
This option is supported only by the versions of
1202
\fBmysqlbinlog\fR
1203
supplied with the MySQL Cluster distribution, or built from the MySQL Cluster sources\&.
1204
.RE
1205
.sp
1206
.RS 4
1207
.ie n \{\
1208
\h'-04'\(bu\h'+03'\c
1209
.\}
1210
.el \{\
1211
.sp -1
1212
.IP \(bu 2.3
1213
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1214
.\" mysqlbinlog: set-charset option
1215
.\" set-charset option: mysqlbinlog
1216
\fB\-\-set\-charset=\fR\fB\fIcharset_name\fR\fR
1 by James Page
Import upstream version 5.6.15
1217
.sp
1218
Add a
1219
SET NAMES \fIcharset_name\fR
1220
statement to the output to specify the character set to be used for processing log files\&.
1221
.RE
1222
.sp
1223
.RS 4
1224
.ie n \{\
1225
\h'-04'\(bu\h'+03'\c
1226
.\}
1227
.el \{\
1228
.sp -1
1229
.IP \(bu 2.3
1230
.\}
1.2.4 by Robie Basak
Import upstream version 5.6.23
1231
.\" mysqlbinlog: shared-memory-base-name option
1232
.\" shared-memory-base-name option: mysqlbinlog
1233
\fB\-\-shared\-memory\-base\-name=\fR\fB\fIname\fR\fR
1234
.sp
1235
On Windows, the shared\-memory name to use, for connections made using shared memory to a local server\&. The default value is
1236
MYSQL\&. The shared\-memory name is case sensitive\&.
1237
.sp
1238
The server must be started with the
1239
\fB\-\-shared\-memory\fR
1240
option to enable shared\-memory connections\&.
1241
.RE
1242
.sp
1243
.RS 4
1244
.ie n \{\
1245
\h'-04'\(bu\h'+03'\c
1246
.\}
1247
.el \{\
1248
.sp -1
1249
.IP \(bu 2.3
1250
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1251
.\" mysqlbinlog: short-form option
1252
.\" short-form option: mysqlbinlog
1253
\fB\-\-short\-form\fR,
1 by James Page
Import upstream version 5.6.15
1254
\fB\-s\fR
1255
.sp
1256
Display only the statements contained in the log, without any extra information or row\-based events\&. This is for testing only, and should not be used in production systems\&.
1257
.RE
1258
.sp
1259
.RS 4
1260
.ie n \{\
1261
\h'-04'\(bu\h'+03'\c
1262
.\}
1263
.el \{\
1264
.sp -1
1265
.IP \(bu 2.3
1266
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1267
.\" mysqlbinlog: skip-gtids option
1268
.\" skip-gtids option: mysqlbinlog
1269
\fB\-\-skip\-gtids[=(true|false)]\fR
1 by James Page
Import upstream version 5.6.15
1270
.sp
1.2.2 by James Page
Import upstream version 5.6.17
1271
Do not display any GTIDs in the output\&. This is needed when writing to a dump file from one or more binary logs containing GTIDs, as shown in this example:
1272
.sp
1273
.if n \{\
1274
.RS 4
1275
.\}
1276
.nf
1277
shell> \fBmysqlbinlog \-\-skip\-gtids binlog\&.000001 >  /tmp/dump\&.sql\fR
1278
shell> \fBmysqlbinlog \-\-skip\-gtids binlog\&.000002 >> /tmp/dump\&.sql\fR
1279
shell> \fBmysql \-u root \-p \-e "source /tmp/dump\&.sql"\fR
1280
.fi
1281
.if n \{\
1282
.RE
1283
.\}
1284
.sp
1285
The use of this option is otherwise not normally recommended in production\&.
1286
.sp
1287
This option was added in MySQL 5\&.6\&.5\&.
1 by James Page
Import upstream version 5.6.15
1288
.RE
1289
.sp
1290
.RS 4
1291
.ie n \{\
1292
\h'-04'\(bu\h'+03'\c
1293
.\}
1294
.el \{\
1295
.sp -1
1296
.IP \(bu 2.3
1297
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1298
.\" mysqlbinlog: socket option
1299
.\" socket option: mysqlbinlog
1300
\fB\-\-socket=\fR\fB\fIpath\fR\fR,
1 by James Page
Import upstream version 5.6.15
1301
\fB\-S \fR\fB\fIpath\fR\fR
1302
.sp
1303
For connections to
1304
localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use\&.
1305
.RE
1306
.sp
1307
.RS 4
1308
.ie n \{\
1309
\h'-04'\(bu\h'+03'\c
1310
.\}
1311
.el \{\
1312
.sp -1
1313
.IP \(bu 2.3
1314
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1315
.\" mysqlbinlog: start-datetime option
1316
.\" start-datetime option: mysqlbinlog
1317
\fB\-\-start\-datetime=\fR\fB\fIdatetime\fR\fR
1 by James Page
Import upstream version 5.6.15
1318
.sp
1319
Start reading the binary log at the first event having a timestamp equal to or later than the
1320
\fIdatetime\fR
1321
argument\&. The
1322
\fIdatetime\fR
1323
value is relative to the local time zone on the machine where you run
1324
\fBmysqlbinlog\fR\&. The value should be in a format accepted for the
1325
DATETIME
1326
or
1327
TIMESTAMP
1328
data types\&. For example:
1329
.sp
1330
.if n \{\
1331
.RS 4
1332
.\}
1333
.nf
1334
shell> \fBmysqlbinlog \-\-start\-datetime="2005\-12\-25 11:25:56" binlog\&.000003\fR
1335
.fi
1336
.if n \{\
1337
.RE
1338
.\}
1339
.sp
1340
This option is useful for point\-in\-time recovery\&. See
1341
Section\ \&7.3, \(lqExample Backup and Recovery Strategy\(rq\&.
1342
.RE
1343
.sp
1344
.RS 4
1345
.ie n \{\
1346
\h'-04'\(bu\h'+03'\c
1347
.\}
1348
.el \{\
1349
.sp -1
1350
.IP \(bu 2.3
1351
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1352
.\" mysqlbinlog: start-position option
1353
.\" start-position option: mysqlbinlog
1354
\fB\-\-start\-position=\fR\fB\fIN\fR\fR,
1 by James Page
Import upstream version 5.6.15
1355
\fB\-j \fR\fB\fIN\fR\fR
1356
.sp
1357
Start reading the binary log at the first event having a position equal to or greater than
1358
\fIN\fR\&. This option applies to the first log file named on the command line\&.
1359
.sp
1360
This option is useful for point\-in\-time recovery\&. See
1361
Section\ \&7.3, \(lqExample Backup and Recovery Strategy\(rq\&.
1362
.RE
1363
.sp
1364
.RS 4
1365
.ie n \{\
1366
\h'-04'\(bu\h'+03'\c
1367
.\}
1368
.el \{\
1369
.sp -1
1370
.IP \(bu 2.3
1371
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1372
.\" mysqlbinlog: stop-datetime option
1373
.\" stop-datetime option: mysqlbinlog
1374
\fB\-\-stop\-datetime=\fR\fB\fIdatetime\fR\fR
1 by James Page
Import upstream version 5.6.15
1375
.sp
1376
Stop reading the binary log at the first event having a timestamp equal to or later than the
1377
\fIdatetime\fR
1378
argument\&. This option is useful for point\-in\-time recovery\&. See the description of the
1379
\fB\-\-start\-datetime\fR
1380
option for information about the
1381
\fIdatetime\fR
1382
value\&.
1383
.sp
1384
This option is useful for point\-in\-time recovery\&. See
1385
Section\ \&7.3, \(lqExample Backup and Recovery Strategy\(rq\&.
1386
.RE
1387
.sp
1388
.RS 4
1389
.ie n \{\
1390
\h'-04'\(bu\h'+03'\c
1391
.\}
1392
.el \{\
1393
.sp -1
1394
.IP \(bu 2.3
1395
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1396
.\" mysqlbinlog: stop-never option
1397
.\" stop-never option: mysqlbinlog
1398
\fB\-\-stop\-never\fR
1 by James Page
Import upstream version 5.6.15
1399
.sp
1400
This option is used with
1401
\fB\-\-read\-from\-remote\-server\fR\&. It tells
1402
\fBmysqlbinlog\fR
1403
to remain connected to the server\&. Otherwise
1404
\fBmysqlbinlog\fR
1405
exits when the last log file has been transferred from the server\&.
1406
\fB\-\-stop\-never\fR
1407
implies
1408
\fB\-\-to\-last\-log\fR, so only the first log file to transfer need be named on the command line\&.
1409
.sp
1410
\fB\-\-stop\-never\fR
1411
is commonly used with
1412
\fB\-\-raw\fR
1413
to make a live binary log backup, but also can be used without
1414
\fB\-\-raw\fR
1415
to maintain a continuous text display of log events as the server generates them\&.
1416
.sp
1417
This option was added in MySQL 5\&.6\&.0\&.
1418
.RE
1419
.sp
1420
.RS 4
1421
.ie n \{\
1422
\h'-04'\(bu\h'+03'\c
1423
.\}
1424
.el \{\
1425
.sp -1
1426
.IP \(bu 2.3
1427
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1428
.\" mysqlbinlog: stop-never-slave-server-id option
1429
.\" stop-never-slave-server-id option: mysqlbinlog
1430
\fB\-\-stop\-never\-slave\-server\-id=\fR\fB\fIid\fR\fR
1 by James Page
Import upstream version 5.6.15
1431
.sp
1432
With
1433
\fB\-\-stop\-never\fR,
1434
\fBmysqlbinlog\fR
1435
reports a server ID of 65535 when it connects to the server\&.
1436
\fB\-\-stop\-never\-slave\-server\-id\fR
1437
explicitly specifies the server ID to report\&. It can be used to avoid a conflict with the ID of a slave server or another
1438
\fBmysqlbinlog\fR
1439
process\&. See
1440
the section called \(lqSPECIFYING THE MYSQLBINLOG SERVER ID\(rq\&.
1441
.sp
1442
This option was added in MySQL 5\&.6\&.0\&.
1443
.RE
1444
.sp
1445
.RS 4
1446
.ie n \{\
1447
\h'-04'\(bu\h'+03'\c
1448
.\}
1449
.el \{\
1450
.sp -1
1451
.IP \(bu 2.3
1452
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1453
.\" mysqlbinlog: stop-position option
1454
.\" stop-position option: mysqlbinlog
1455
\fB\-\-stop\-position=\fR\fB\fIN\fR\fR
1 by James Page
Import upstream version 5.6.15
1456
.sp
1457
Stop reading the binary log at the first event having a position equal to or greater than
1458
\fIN\fR\&. This option applies to the last log file named on the command line\&.
1459
.sp
1460
This option is useful for point\-in\-time recovery\&. See
1461
Section\ \&7.3, \(lqExample Backup and Recovery Strategy\(rq\&.
1462
.RE
1463
.sp
1464
.RS 4
1465
.ie n \{\
1466
\h'-04'\(bu\h'+03'\c
1467
.\}
1468
.el \{\
1469
.sp -1
1470
.IP \(bu 2.3
1471
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1472
.\" mysqlbinlog: to-last-log option
1473
.\" to-last-log option: mysqlbinlog
1474
\fB\-\-to\-last\-log\fR,
1 by James Page
Import upstream version 5.6.15
1475
\fB\-t\fR
1476
.sp
1477
Do not stop at the end of the requested binary log from a MySQL server, but rather continue printing until the end of the last binary log\&. If you send the output to the same MySQL server, this may lead to an endless loop\&. This option requires
1478
\fB\-\-read\-from\-remote\-server\fR\&.
1479
.RE
1480
.sp
1481
.RS 4
1482
.ie n \{\
1483
\h'-04'\(bu\h'+03'\c
1484
.\}
1485
.el \{\
1486
.sp -1
1487
.IP \(bu 2.3
1488
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1489
.\" mysqlbinlog: user option
1490
.\" user option: mysqlbinlog
1491
\fB\-\-user=\fR\fB\fIuser_name\fR\fR,
1 by James Page
Import upstream version 5.6.15
1492
\fB\-u \fR\fB\fIuser_name\fR\fR
1493
.sp
1494
The MySQL user name to use when connecting to a remote server\&.
1495
.RE
1496
.sp
1497
.RS 4
1498
.ie n \{\
1499
\h'-04'\(bu\h'+03'\c
1500
.\}
1501
.el \{\
1502
.sp -1
1503
.IP \(bu 2.3
1504
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1505
.\" mysqlbinlog: verbose option
1506
.\" verbose option: mysqlbinlog
1507
\fB\-\-verbose\fR,
1 by James Page
Import upstream version 5.6.15
1508
\fB\-v\fR
1509
.sp
1510
Reconstruct row events and display them as commented SQL statements\&. If this option is given twice, the output includes comments to indicate column data types and some metadata\&.
1511
.sp
1512
For examples that show the effect of
1513
\fB\-\-base64\-output\fR
1514
and
1515
\fB\-\-verbose\fR
1516
on row event output, see
1517
the section called \(lqMYSQLBINLOG ROW EVENT DISPLAY\(rq\&.
1518
.RE
1519
.sp
1520
.RS 4
1521
.ie n \{\
1522
\h'-04'\(bu\h'+03'\c
1523
.\}
1524
.el \{\
1525
.sp -1
1526
.IP \(bu 2.3
1527
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1528
.\" mysqlbinlog: verify-binlog-checksum option
1529
.\" verify-binlog-checksum option: mysqlbinlog
1530
\fB\-\-verify\-binlog\-checksum\fR,
1 by James Page
Import upstream version 5.6.15
1531
\fB\-c\fR
1532
.sp
1533
Verify checksums in binary log files\&. This option was added in MySQL 5\&.6\&.1\&.
1534
.RE
1535
.sp
1536
.RS 4
1537
.ie n \{\
1538
\h'-04'\(bu\h'+03'\c
1539
.\}
1540
.el \{\
1541
.sp -1
1542
.IP \(bu 2.3
1543
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1544
.\" mysqlbinlog: version option
1545
.\" version option: mysqlbinlog
1546
\fB\-\-version\fR,
1 by James Page
Import upstream version 5.6.15
1547
\fB\-V\fR
1548
.sp
1549
Display version information and exit\&.
1550
.sp
1551
Prior to MySQL 5\&.6\&.11, the
1552
\fBmysqlbinlog\fR
1553
version number shown was 3\&.3\&. In MySQL 5\&.6\&.11 and later, this is 3\&.4\&. (Bug #15894381, Bug #67643)
1554
.RE
1555
.PP
1556
You can also set the following variable by using
1557
\fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR
1558
syntax:
1559
.sp
1560
.RS 4
1561
.ie n \{\
1562
\h'-04'\(bu\h'+03'\c
1563
.\}
1564
.el \{\
1565
.sp -1
1566
.IP \(bu 2.3
1567
.\}
1.2.1 by James Page
Import upstream version 5.6.16
1568
.\" open_files_limit variable
1569
open_files_limit
1 by James Page
Import upstream version 5.6.15
1570
.sp
1571
Specify the number of open file descriptors to reserve\&.
1572
.RE
1573
.PP
1574
You can pipe the output of
1575
\fBmysqlbinlog\fR
1576
into the
1577
\fBmysql\fR
1578
client to execute the events contained in the binary log\&. This technique is used to recover from a crash when you have an old backup (see
1579
Section\ \&7.5, \(lqPoint-in-Time (Incremental) Recovery Using the Binary Log\(rq)\&. For example:
1580
.sp
1581
.if n \{\
1582
.RS 4
1583
.\}
1584
.nf
1585
shell> \fBmysqlbinlog binlog\&.000001 | mysql \-u root \-p\fR
1586
.fi
1587
.if n \{\
1588
.RE
1589
.\}
1590
.PP
1591
Or:
1592
.sp
1593
.if n \{\
1594
.RS 4
1595
.\}
1596
.nf
1597
shell> \fBmysqlbinlog binlog\&.[0\-9]* | mysql \-u root \-p\fR
1598
.fi
1599
.if n \{\
1600
.RE
1601
.\}
1602
.PP
1603
If the statements produced by
1604
\fBmysqlbinlog\fR
1605
may contain
1606
BLOB
1607
values, these may cause problems when
1608
\fBmysql\fR
1609
processes them\&. In this case, invoke
1610
\fBmysql\fR
1611
with the
1612
\fB\-\-binary\-mode\fR
1613
option\&.
1614
.PP
1615
You can also redirect the output of
1616
\fBmysqlbinlog\fR
1617
to a text file instead, if you need to modify the statement log first (for example, to remove statements that you do not want to execute for some reason)\&. After editing the file, execute the statements that it contains by using it as input to the
1618
\fBmysql\fR
1619
program:
1620
.sp
1621
.if n \{\
1622
.RS 4
1623
.\}
1624
.nf
1625
shell> \fBmysqlbinlog binlog\&.000001 > tmpfile\fR
1626
shell> \&.\&.\&. \fIedit tmpfile\fR \&.\&.\&.
1627
shell> \fBmysql \-u root \-p < tmpfile\fR
1628
.fi
1629
.if n \{\
1630
.RE
1631
.\}
1632
.PP
1633
When
1634
\fBmysqlbinlog\fR
1635
is invoked with the
1636
\fB\-\-start\-position\fR
1637
option, it displays only those events with an offset in the binary log greater than or equal to a given position (the given position must match the start of one event)\&. It also has options to stop and start when it sees an event with a given date and time\&. This enables you to perform point\-in\-time recovery using the
1638
\fB\-\-stop\-datetime\fR
1639
option (to be able to say, for example,
1640
\(lqroll forward my databases to how they were today at 10:30 a\&.m\&.\(rq)\&.
1641
.PP
1642
If you have more than one binary log to execute on the MySQL server, the safe method is to process them all using a single connection to the server\&. Here is an example that demonstrates what may be
1643
\fIunsafe\fR:
1644
.sp
1645
.if n \{\
1646
.RS 4
1647
.\}
1648
.nf
1649
shell> \fBmysqlbinlog binlog\&.000001 | mysql \-u root \-p # DANGER!!\fR
1650
shell> \fBmysqlbinlog binlog\&.000002 | mysql \-u root \-p # DANGER!!\fR
1651
.fi
1652
.if n \{\
1653
.RE
1654
.\}
1655
.PP
1656
Processing binary logs this way using multiple connections to the server causes problems if the first log file contains a
1657
CREATE TEMPORARY TABLE
1658
statement and the second log contains a statement that uses the temporary table\&. When the first
1659
\fBmysql\fR
1660
process terminates, the server drops the temporary table\&. When the second
1661
\fBmysql\fR
1662
process attempts to use the table, the server reports
1663
\(lqunknown table\&.\(rq
1664
.PP
1665
To avoid problems like this, use a
1.2.1 by James Page
Import upstream version 5.6.16
1666
\fIsingle\fR
1667
\fBmysql\fR
1 by James Page
Import upstream version 5.6.15
1668
process to execute the contents of all binary logs that you want to process\&. Here is one way to do so:
1669
.sp
1670
.if n \{\
1671
.RS 4
1672
.\}
1673
.nf
1674
shell> \fBmysqlbinlog binlog\&.000001 binlog\&.000002 | mysql \-u root \-p\fR
1675
.fi
1676
.if n \{\
1677
.RE
1678
.\}
1679
.PP
1680
Another approach is to write all the logs to a single file and then process the file:
1681
.sp
1682
.if n \{\
1683
.RS 4
1684
.\}
1685
.nf
1686
shell> \fBmysqlbinlog binlog\&.000001 >  /tmp/statements\&.sql\fR
1687
shell> \fBmysqlbinlog binlog\&.000002 >> /tmp/statements\&.sql\fR
1688
shell> \fBmysql \-u root \-p \-e "source /tmp/statements\&.sql"\fR
1689
.fi
1690
.if n \{\
1691
.RE
1692
.\}
1693
.PP
1694
\fBmysqlbinlog\fR
1695
can produce output that reproduces a
1696
LOAD DATA INFILE
1697
operation without the original data file\&.
1698
\fBmysqlbinlog\fR
1699
copies the data to a temporary file and writes a
1700
LOAD DATA LOCAL INFILE
1701
statement that refers to the file\&. The default location of the directory where these files are written is system\-specific\&. To specify a directory explicitly, use the
1702
\fB\-\-local\-load\fR
1703
option\&.
1704
.PP
1705
Because
1706
\fBmysqlbinlog\fR
1707
converts
1708
LOAD DATA INFILE
1709
statements to
1710
LOAD DATA LOCAL INFILE
1711
statements (that is, it adds
1712
LOCAL), both the client and the server that you use to process the statements must be configured with the
1713
LOCAL
1714
capability enabled\&. See
1715
Section\ \&6.1.6, \(lqSecurity Issues with LOAD DATA LOCAL\(rq\&.
1716
.if n \{\
1717
.sp
1718
.\}
1719
.RS 4
1720
.it 1 an-trap
1721
.nr an-no-space-flag 1
1722
.nr an-break-flag 1
1723
.br
1724
.ps +1
1725
\fBWarning\fR
1726
.ps -1
1727
.br
1728
.PP
1729
The temporary files created for
1730
LOAD DATA LOCAL
1731
statements are
1732
\fInot\fR
1733
automatically deleted because they are needed until you actually execute those statements\&. You should delete the temporary files yourself after you no longer need the statement log\&. The files can be found in the temporary file directory and have names like
1734
\fIoriginal_file_name\-#\-#\fR\&.
1735
.sp .5v
1736
.RE
1737
.SH "MYSQLBINLOG HEX DUMP FORMAT"
1738
.PP
1739
The
1740
\fB\-\-hexdump\fR
1741
option causes
1742
\fBmysqlbinlog\fR
1743
to produce a hex dump of the binary log contents:
1744
.sp
1745
.if n \{\
1746
.RS 4
1747
.\}
1748
.nf
1749
shell> \fBmysqlbinlog \-\-hexdump master\-bin\&.000001\fR
1750
.fi
1751
.if n \{\
1752
.RE
1753
.\}
1754
.PP
1755
The hex output consists of comment lines beginning with
1756
#, so the output might look like this for the preceding command:
1757
.sp
1758
.if n \{\
1759
.RS 4
1760
.\}
1761
.nf
1762
/*!40019 SET @@session\&.max_insert_delayed_threads=0*/;
1763
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
1764
# at 4
1765
#051024 17:24:13 server id 1  end_log_pos 98
1766
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags
1767
# 00000004 9d fc 5c 43   0f   01 00 00 00   5e 00 00 00   62 00 00 00   00 00
1768
# 00000017 04 00 35 2e 30 2e 31 35  2d 64 65 62 75 67 2d 6c |\&.\&.5\&.0\&.15\&.debug\&.l|
1769
# 00000027 6f 67 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |og\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.|
1770
# 00000037 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.\&.|
1771
# 00000047 00 00 00 00 9d fc 5c 43  13 38 0d 00 08 00 12 00 |\&.\&.\&.\&.\&.\&.\&.C\&.8\&.\&.\&.\&.\&.\&.|
1772
# 00000057 04 04 04 04 12 00 00 4b  00 04 1a                |\&.\&.\&.\&.\&.\&.\&.K\&.\&.\&.|
1773
#       Start: binlog v 4, server v 5\&.0\&.15\-debug\-log created 051024 17:24:13
1774
#       at startup
1775
ROLLBACK;
1776
.fi
1777
.if n \{\
1778
.RE
1779
.\}
1780
.PP
1781
Hex dump output currently contains the elements in the following list\&. This format is subject to change\&. (For more information about binary log format, see
1782
\m[blue]\fBMySQL Internals: The Binary Log\fR\m[]\&\s-2\u[1]\d\s+2\&.
1783
.sp
1784
.RS 4
1785
.ie n \{\
1786
\h'-04'\(bu\h'+03'\c
1787
.\}
1788
.el \{\
1789
.sp -1
1790
.IP \(bu 2.3
1791
.\}
1792
Position: The byte position within the log file\&.
1793
.RE
1794
.sp
1795
.RS 4
1796
.ie n \{\
1797
\h'-04'\(bu\h'+03'\c
1798
.\}
1799
.el \{\
1800
.sp -1
1801
.IP \(bu 2.3
1802
.\}
1803
Timestamp: The event timestamp\&. In the example shown,
1804
\*(Aq9d fc 5c 43\*(Aq
1805
is the representation of
1806
\*(Aq051024 17:24:13\*(Aq
1807
in hexadecimal\&.
1808
.RE
1809
.sp
1810
.RS 4
1811
.ie n \{\
1812
\h'-04'\(bu\h'+03'\c
1813
.\}
1814
.el \{\
1815
.sp -1
1816
.IP \(bu 2.3
1817
.\}
1818
Type: The event type code\&. In the example shown,
1819
\*(Aq0f\*(Aq
1820
indicates a
1821
FORMAT_DESCRIPTION_EVENT\&. The following table lists the possible type codes\&.
1822
.TS
1823
allbox tab(:);
1824
lB lB lB.
1825
T{
1826
Type
1827
T}:T{
1828
Name
1829
T}:T{
1830
Meaning
1831
T}
1832
.T&
1833
l l l
1834
l l l
1835
l l l
1836
l l l
1837
l l l
1838
l l l
1839
l l l
1840
l l l
1841
l l l
1842
l l l
1843
l l l
1844
l l l
1845
l l l
1846
l l l
1847
l l l
1848
l l l
1849
l l l
1850
l l l
1851
l l l
1852
l l l
1853
l l l
1854
l l l
1855
l l l
1856
l l l
1857
l l l
1858
l l l
1859
l l l.
1860
T{
1861
00
1862
T}:T{
1863
UNKNOWN_EVENT
1864
T}:T{
1865
This event should never be present in the log\&.
1866
T}
1867
T{
1868
01
1869
T}:T{
1870
START_EVENT_V3
1871
T}:T{
1872
This indicates the start of a log file written by MySQL 4 or earlier\&.
1873
T}
1874
T{
1875
02
1876
T}:T{
1877
QUERY_EVENT
1878
T}:T{
1879
The most common type of events\&. These contain statements executed on the
1880
                    master\&.
1881
T}
1882
T{
1883
03
1884
T}:T{
1885
STOP_EVENT
1886
T}:T{
1887
Indicates that master has stopped\&.
1888
T}
1889
T{
1890
04
1891
T}:T{
1892
ROTATE_EVENT
1893
T}:T{
1894
Written when the master switches to a new log file\&.
1895
T}
1896
T{
1897
05
1898
T}:T{
1899
INTVAR_EVENT
1900
T}:T{
1901
Used for AUTO_INCREMENT values or when the
1902
                    LAST_INSERT_ID()
1903
                    function is used in the statement\&.
1904
T}
1905
T{
1906
06
1907
T}:T{
1908
LOAD_EVENT
1909
T}:T{
1910
Used for LOAD DATA
1911
                    INFILE in MySQL 3\&.23\&.
1912
T}
1913
T{
1914
07
1915
T}:T{
1916
SLAVE_EVENT
1917
T}:T{
1918
Reserved for future use\&.
1919
T}
1920
T{
1921
08
1922
T}:T{
1923
CREATE_FILE_EVENT
1924
T}:T{
1925
Used for LOAD DATA
1926
                    INFILE statements\&. This indicates the
1927
                    start of execution of such a statement\&. A temporary
1928
                    file is created on the slave\&. Used in MySQL 4 only\&.
1929
T}
1930
T{
1931
09
1932
T}:T{
1933
APPEND_BLOCK_EVENT
1934
T}:T{
1935
Contains data for use in a
1936
                    LOAD DATA
1937
                    INFILE statement\&. The data is stored in
1938
                    the temporary file on the slave\&.
1939
T}
1940
T{
1941
0a
1942
T}:T{
1943
EXEC_LOAD_EVENT
1944
T}:T{
1945
Used for LOAD DATA
1946
                    INFILE statements\&. The contents of the
1947
                    temporary file is stored in the table on the slave\&.
1948
                    Used in MySQL 4 only\&.
1949
T}
1950
T{
1951
0b
1952
T}:T{
1953
DELETE_FILE_EVENT
1954
T}:T{
1955
Rollback of a LOAD DATA
1956
                    INFILE statement\&. The temporary file
1957
                    should be deleted on the slave\&.
1958
T}
1959
T{
1960
0c
1961
T}:T{
1962
NEW_LOAD_EVENT
1963
T}:T{
1964
Used for LOAD DATA
1965
                    INFILE in MySQL 4 and earlier\&.
1966
T}
1967
T{
1968
0d
1969
T}:T{
1970
RAND_EVENT
1971
T}:T{
1972
Used to send information about random values if the
1973
                    RAND() function is
1974
                    used in the statement\&.
1975
T}
1976
T{
1977
0e
1978
T}:T{
1979
USER_VAR_EVENT
1980
T}:T{
1981
Used to replicate user variables\&.
1982
T}
1983
T{
1984
0f
1985
T}:T{
1986
FORMAT_DESCRIPTION_EVENT
1987
T}:T{
1988
This indicates the start of a log file written by MySQL 5 or later\&.
1989
T}
1990
T{
1991
10
1992
T}:T{
1993
XID_EVENT
1994
T}:T{
1995
Event indicating commit of an XA transaction\&.
1996
T}
1997
T{
1998
11
1999
T}:T{
2000
BEGIN_LOAD_QUERY_EVENT
2001
T}:T{
2002
Used for LOAD DATA
2003
                    INFILE statements in MySQL 5 and later\&.
2004
T}
2005
T{
2006
12
2007
T}:T{
2008
EXECUTE_LOAD_QUERY_EVENT
2009
T}:T{
2010
Used for LOAD DATA
2011
                    INFILE statements in MySQL 5 and later\&.
2012
T}
2013
T{
2014
13
2015
T}:T{
2016
TABLE_MAP_EVENT
2017
T}:T{
2018
Information about a table definition\&. Used in MySQL 5\&.1\&.5 and later\&.
2019
T}
2020
T{
2021
14
2022
T}:T{
2023
PRE_GA_WRITE_ROWS_EVENT
2024
T}:T{
2025
Row data for a single table that should be created\&. Used in MySQL 5\&.1\&.5
2026
                    to 5\&.1\&.17\&.
2027
T}
2028
T{
2029
15
2030
T}:T{
2031
PRE_GA_UPDATE_ROWS_EVENT
2032
T}:T{
2033
Row data for a single table that needs to be updated\&. Used in MySQL
2034
                    5\&.1\&.5 to 5\&.1\&.17\&.
2035
T}
2036
T{
2037
16
2038
T}:T{
2039
PRE_GA_DELETE_ROWS_EVENT
2040
T}:T{
2041
Row data for a single table that should be deleted\&. Used in MySQL 5\&.1\&.5
2042
                    to 5\&.1\&.17\&.
2043
T}
2044
T{
2045
17
2046
T}:T{
2047
WRITE_ROWS_EVENT
2048
T}:T{
2049
Row data for a single table that should be created\&. Used in MySQL 5\&.1\&.18
2050
                    and later\&.
2051
T}
2052
T{
2053
18
2054
T}:T{
2055
UPDATE_ROWS_EVENT
2056
T}:T{
2057
Row data for a single table that needs to be updated\&. Used in MySQL
2058
                    5\&.1\&.18 and later\&.
2059
T}
2060
T{
2061
19
2062
T}:T{
2063
DELETE_ROWS_EVENT
2064
T}:T{
2065
Row data for a single table that should be deleted\&. Used in MySQL 5\&.1\&.18
2066
                    and later\&.
2067
T}
2068
T{
2069
1a
2070
T}:T{
2071
INCIDENT_EVENT
2072
T}:T{
2073
Something out of the ordinary happened\&. Added in MySQL 5\&.1\&.18\&.
2074
T}
2075
.TE
2076
.sp 1
2077
.RE
2078
.sp
2079
.RS 4
2080
.ie n \{\
2081
\h'-04'\(bu\h'+03'\c
2082
.\}
2083
.el \{\
2084
.sp -1
2085
.IP \(bu 2.3
2086
.\}
2087
Master ID: The server ID of the master that created the event\&.
2088
.RE
2089
.sp
2090
.RS 4
2091
.ie n \{\
2092
\h'-04'\(bu\h'+03'\c
2093
.\}
2094
.el \{\
2095
.sp -1
2096
.IP \(bu 2.3
2097
.\}
2098
Size: The size in bytes of the event\&.
2099
.RE
2100
.sp
2101
.RS 4
2102
.ie n \{\
2103
\h'-04'\(bu\h'+03'\c
2104
.\}
2105
.el \{\
2106
.sp -1
2107
.IP \(bu 2.3
2108
.\}
2109
Master Pos: The position of the next event in the original master log file\&.
2110
.RE
2111
.sp
2112
.RS 4
2113
.ie n \{\
2114
\h'-04'\(bu\h'+03'\c
2115
.\}
2116
.el \{\
2117
.sp -1
2118
.IP \(bu 2.3
2119
.\}
2120
Flags: 16 flags\&. Currently, the following flags are used\&. The others are reserved for future use\&.
2121
.TS
2122
allbox tab(:);
2123
lB lB lB.
2124
T{
2125
Flag
2126
T}:T{
2127
Name
2128
T}:T{
2129
Meaning
2130
T}
2131
.T&
2132
l l l
2133
l l l
2134
l l l
2135
l l l.
2136
T{
2137
01
2138
T}:T{
2139
LOG_EVENT_BINLOG_IN_USE_F
2140
T}:T{
2141
Log file correctly closed\&. (Used only in
2142
                    FORMAT_DESCRIPTION_EVENT\&.) If
2143
                    this flag is set (if the flags are, for example,
2144
                    \*(Aq01 00\*(Aq) in a
2145
                    FORMAT_DESCRIPTION_EVENT, the log
2146
                    file has not been properly closed\&. Most probably
2147
                    this is because of a master crash (for example, due
2148
                    to power failure)\&.
2149
T}
2150
T{
2151
02
2152
T}:T{
2153
\ \&
2154
T}:T{
2155
Reserved for future use\&.
2156
T}
2157
T{
2158
04
2159
T}:T{
2160
LOG_EVENT_THREAD_SPECIFIC_F
2161
T}:T{
2162
Set if the event is dependent on the connection it was executed in (for
2163
                    example, \*(Aq04 00\*(Aq), for example,
2164
                    if the event uses temporary tables\&.
2165
T}
2166
T{
2167
08
2168
T}:T{
2169
LOG_EVENT_SUPPRESS_USE_F
2170
T}:T{
2171
Set in some circumstances when the event is not dependent on the default
2172
                    database\&.
2173
T}
2174
.TE
2175
.sp 1
2176
.RE
2177
.SH "MYSQLBINLOG ROW EVENT DISPLAY"
2178
.\" BINLOG statement: mysqlbinlog output
2179
.PP
2180
The following examples illustrate how
2181
\fBmysqlbinlog\fR
2182
displays row events that specify data modifications\&. These correspond to events with the
2183
WRITE_ROWS_EVENT,
2184
UPDATE_ROWS_EVENT, and
2185
DELETE_ROWS_EVENT
2186
type codes\&. The
2187
\fB\-\-base64\-output=DECODE\-ROWS\fR
2188
and
2189
\fB\-\-verbose\fR
2190
options may be used to affect row event output\&.
2191
.PP
2192
Suppose that the server is using row\-based binary logging and that you execute the following sequence of statements:
2193
.sp
2194
.if n \{\
2195
.RS 4
2196
.\}
2197
.nf
2198
CREATE TABLE t
2199
(
2200
  id   INT NOT NULL,
2201
  name VARCHAR(20) NOT NULL,
2202
  date DATE NULL
2203
) ENGINE = InnoDB;
2204
START TRANSACTION;
2205
INSERT INTO t VALUES(1, \*(Aqapple\*(Aq, NULL);
2206
UPDATE t SET name = \*(Aqpear\*(Aq, date = \*(Aq2009\-01\-01\*(Aq WHERE id = 1;
2207
DELETE FROM t WHERE id = 1;
2208
COMMIT;
2209
.fi
2210
.if n \{\
2211
.RE
2212
.\}
2213
.PP
2214
By default,
2215
\fBmysqlbinlog\fR
2216
displays row events encoded as base\-64 strings using
2217
BINLOG
2218
statements\&. Omitting extraneous lines, the output for the row events produced by the preceding statement sequence looks like this:
2219
.sp
2220
.if n \{\
2221
.RS 4
2222
.\}
2223
.nf
2224
shell> \fBmysqlbinlog \fR\fB\fIlog_file\fR\fR
2225
\&.\&.\&.
2226
# at 218
2227
#080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
2228
BINLOG \*(Aq
2229
fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2230
fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
2231
\*(Aq/*!*/;
2232
\&.\&.\&.
2233
# at 302
2234
#080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
2235
BINLOG \*(Aq
2236
fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2237
fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
2238
\*(Aq/*!*/;
2239
\&.\&.\&.
2240
# at 400
2241
#080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
2242
BINLOG \*(Aq
2243
fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2244
fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
2245
\*(Aq/*!*/;
2246
.fi
2247
.if n \{\
2248
.RE
2249
.\}
2250
.PP
2251
To see the row events as comments in the form of
2252
\(lqpseudo\-SQL\(rq
2253
statements, run
2254
\fBmysqlbinlog\fR
2255
with the
2256
\fB\-\-verbose\fR
2257
or
2258
\fB\-v\fR
2259
option\&. The output will contain lines beginning with
2260
###:
2261
.sp
2262
.if n \{\
2263
.RS 4
2264
.\}
2265
.nf
2266
shell> \fBmysqlbinlog \-v \fR\fB\fIlog_file\fR\fR
2267
\&.\&.\&.
2268
# at 218
2269
#080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
2270
BINLOG \*(Aq
2271
fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2272
fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
2273
\*(Aq/*!*/;
2274
### INSERT INTO test\&.t
2275
### SET
2276
###   @1=1
2277
###   @2=\*(Aqapple\*(Aq
2278
###   @3=NULL
2279
\&.\&.\&.
2280
# at 302
2281
#080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
2282
BINLOG \*(Aq
2283
fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2284
fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
2285
\*(Aq/*!*/;
2286
### UPDATE test\&.t
2287
### WHERE
2288
###   @1=1
2289
###   @2=\*(Aqapple\*(Aq
2290
###   @3=NULL
2291
### SET
2292
###   @1=1
2293
###   @2=\*(Aqpear\*(Aq
2294
###   @3=\*(Aq2009:01:01\*(Aq
2295
\&.\&.\&.
2296
# at 400
2297
#080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
2298
BINLOG \*(Aq
2299
fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2300
fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
2301
\*(Aq/*!*/;
2302
### DELETE FROM test\&.t
2303
### WHERE
2304
###   @1=1
2305
###   @2=\*(Aqpear\*(Aq
2306
###   @3=\*(Aq2009:01:01\*(Aq
2307
.fi
2308
.if n \{\
2309
.RE
2310
.\}
2311
.PP
2312
Specify
2313
\fB\-\-verbose\fR
2314
or
2315
\fB\-v\fR
2316
twice to also display data types and some metadata for each column\&. The output will contain an additional comment following each column change:
2317
.sp
2318
.if n \{\
2319
.RS 4
2320
.\}
2321
.nf
2322
shell> \fBmysqlbinlog \-vv \fR\fB\fIlog_file\fR\fR
2323
\&.\&.\&.
2324
# at 218
2325
#080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
2326
BINLOG \*(Aq
2327
fAS3SBMBAAAALAAAANoAAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2328
fAS3SBcBAAAAKAAAAAIBAAAQABEAAAAAAAEAA//8AQAAAAVhcHBsZQ==
2329
\*(Aq/*!*/;
2330
### INSERT INTO test\&.t
2331
### SET
2332
###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
2333
###   @2=\*(Aqapple\*(Aq /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
2334
###   @3=NULL /* VARSTRING(20) meta=0 nullable=1 is_null=1 */
2335
\&.\&.\&.
2336
# at 302
2337
#080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
2338
BINLOG \*(Aq
2339
fAS3SBMBAAAALAAAAC4BAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2340
fAS3SBgBAAAANgAAAGQBAAAQABEAAAAAAAEAA////AEAAAAFYXBwbGX4AQAAAARwZWFyIbIP
2341
\*(Aq/*!*/;
2342
### UPDATE test\&.t
2343
### WHERE
2344
###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
2345
###   @2=\*(Aqapple\*(Aq /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
2346
###   @3=NULL /* VARSTRING(20) meta=0 nullable=1 is_null=1 */
2347
### SET
2348
###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
2349
###   @2=\*(Aqpear\*(Aq /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
2350
###   @3=\*(Aq2009:01:01\*(Aq /* DATE meta=0 nullable=1 is_null=0 */
2351
\&.\&.\&.
2352
# at 400
2353
#080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
2354
BINLOG \*(Aq
2355
fAS3SBMBAAAALAAAAJABAAAAABEAAAAAAAAABHRlc3QAAXQAAwMPCgIUAAQ=
2356
fAS3SBkBAAAAKgAAALoBAAAQABEAAAAAAAEAA//4AQAAAARwZWFyIbIP
2357
\*(Aq/*!*/;
2358
### DELETE FROM test\&.t
2359
### WHERE
2360
###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
2361
###   @2=\*(Aqpear\*(Aq /* VARSTRING(20) meta=20 nullable=0 is_null=0 */
2362
###   @3=\*(Aq2009:01:01\*(Aq /* DATE meta=0 nullable=1 is_null=0 */
2363
.fi
2364
.if n \{\
2365
.RE
2366
.\}
2367
.PP
2368
You can tell
2369
\fBmysqlbinlog\fR
2370
to suppress the
2371
BINLOG
2372
statements for row events by using the
2373
\fB\-\-base64\-output=DECODE\-ROWS\fR
2374
option\&. This is similar to
2375
\fB\-\-base64\-output=NEVER\fR
2376
but does not exit with an error if a row event is found\&. The combination of
2377
\fB\-\-base64\-output=DECODE\-ROWS\fR
2378
and
2379
\fB\-\-verbose\fR
2380
provides a convenient way to see row events only as SQL statements:
2381
.sp
2382
.if n \{\
2383
.RS 4
2384
.\}
2385
.nf
2386
shell> \fBmysqlbinlog \-v \-\-base64\-output=DECODE\-ROWS \fR\fB\fIlog_file\fR\fR
2387
\&.\&.\&.
2388
# at 218
2389
#080828 15:03:08 server id 1  end_log_pos 258   Write_rows: table id 17 flags: STMT_END_F
2390
### INSERT INTO test\&.t
2391
### SET
2392
###   @1=1
2393
###   @2=\*(Aqapple\*(Aq
2394
###   @3=NULL
2395
\&.\&.\&.
2396
# at 302
2397
#080828 15:03:08 server id 1  end_log_pos 356   Update_rows: table id 17 flags: STMT_END_F
2398
### UPDATE test\&.t
2399
### WHERE
2400
###   @1=1
2401
###   @2=\*(Aqapple\*(Aq
2402
###   @3=NULL
2403
### SET
2404
###   @1=1
2405
###   @2=\*(Aqpear\*(Aq
2406
###   @3=\*(Aq2009:01:01\*(Aq
2407
\&.\&.\&.
2408
# at 400
2409
#080828 15:03:08 server id 1  end_log_pos 442   Delete_rows: table id 17 flags: STMT_END_F
2410
### DELETE FROM test\&.t
2411
### WHERE
2412
###   @1=1
2413
###   @2=\*(Aqpear\*(Aq
2414
###   @3=\*(Aq2009:01:01\*(Aq
2415
.fi
2416
.if n \{\
2417
.RE
2418
.\}
2419
.sp
2420
.if n \{\
2421
.sp
2422
.\}
2423
.RS 4
2424
.it 1 an-trap
2425
.nr an-no-space-flag 1
2426
.nr an-break-flag 1
2427
.br
2428
.ps +1
2429
\fBNote\fR
2430
.ps -1
2431
.br
2432
.PP
2433
You should not suppress
2434
BINLOG
2435
statements if you intend to re\-execute
2436
\fBmysqlbinlog\fR
2437
output\&.
2438
.sp .5v
2439
.RE
2440
.PP
2441
The SQL statements produced by
2442
\fB\-\-verbose\fR
2443
for row events are much more readable than the corresponding
2444
BINLOG
2445
statements\&. However, they do not correspond exactly to the original SQL statements that generated the events\&. The following limitations apply:
2446
.sp
2447
.RS 4
2448
.ie n \{\
2449
\h'-04'\(bu\h'+03'\c
2450
.\}
2451
.el \{\
2452
.sp -1
2453
.IP \(bu 2.3
2454
.\}
2455
The original column names are lost and replaced by
2456
@\fIN\fR, where
2457
\fIN\fR
2458
is a column number\&.
2459
.RE
2460
.sp
2461
.RS 4
2462
.ie n \{\
2463
\h'-04'\(bu\h'+03'\c
2464
.\}
2465
.el \{\
2466
.sp -1
2467
.IP \(bu 2.3
2468
.\}
2469
Character set information is not available in the binary log, which affects string column display:
2470
.sp
2471
.RS 4
2472
.ie n \{\
2473
\h'-04'\(bu\h'+03'\c
2474
.\}
2475
.el \{\
2476
.sp -1
2477
.IP \(bu 2.3
2478
.\}
2479
There is no distinction made between corresponding binary and nonbinary string types (BINARY
2480
and
2481
CHAR,
2482
VARBINARY
2483
and
2484
VARCHAR,
2485
BLOB
2486
and
2487
TEXT)\&. The output uses a data type of
2488
STRING
2489
for fixed\-length strings and
2490
VARSTRING
2491
for variable\-length strings\&.
2492
.RE
2493
.sp
2494
.RS 4
2495
.ie n \{\
2496
\h'-04'\(bu\h'+03'\c
2497
.\}
2498
.el \{\
2499
.sp -1
2500
.IP \(bu 2.3
2501
.\}
1.2.4 by Robie Basak
Import upstream version 5.6.23
2502
For multibyte character sets, the maximum number of bytes per character is not present in the binary log, so the length for string types is displayed in bytes rather than in characters\&. For example,
1 by James Page
Import upstream version 5.6.15
2503
STRING(4)
2504
will be used as the data type for values from either of these column types:
2505
.sp
2506
.if n \{\
2507
.RS 4
2508
.\}
2509
.nf
2510
CHAR(4) CHARACTER SET latin1
2511
CHAR(2) CHARACTER SET ucs2
2512
.fi
2513
.if n \{\
2514
.RE
2515
.\}
2516
.RE
2517
.sp
2518
.RS 4
2519
.ie n \{\
2520
\h'-04'\(bu\h'+03'\c
2521
.\}
2522
.el \{\
2523
.sp -1
2524
.IP \(bu 2.3
2525
.\}
2526
Due to the storage format for events of type
2527
UPDATE_ROWS_EVENT,
2528
UPDATE
2529
statements are displayed with the
2530
WHERE
2531
clause preceding the
2532
SET
2533
clause\&.
2534
.RE
2535
.RE
2536
.PP
2537
Proper interpretation of row events requires the information from the format description event at the beginning of the binary log\&. Because
2538
\fBmysqlbinlog\fR
2539
does not know in advance whether the rest of the log contains row events, by default it displays the format description event using a
2540
BINLOG
2541
statement in the initial part of the output\&.
2542
.PP
2543
If the binary log is known not to contain any events requiring a
2544
BINLOG
2545
statement (that is, no row events), the
2546
\fB\-\-base64\-output=NEVER\fR
2547
option can be used to prevent this header from being written\&.
2548
.SH "USING MYSQLBINLOG TO BACK UP BINARY LOG FILES"
2549
.PP
2550
By default,
2551
\fBmysqlbinlog\fR
2552
reads binary log files and displays their contents in text format\&. This enables you to examine events within the files more easily and to re\-execute them (for example, by using the output as input to
2553
\fBmysql\fR)\&.
2554
\fBmysqlbinlog\fR
2555
can read log files directly from the local file system, or, with the
2556
\fB\-\-read\-from\-remote\-server\fR
2557
option, it can connect to a server and request binary log contents from that server\&.
2558
\fBmysqlbinlog\fR
2559
writes text output to its standard output, or to the file named as the value of the
2560
\fB\-\-result\-file=\fR\fB\fIfile_name\fR\fR
2561
option if that option is given\&.
2562
.PP
2563
As of MySQL 5\&.6,
2564
\fBmysqlbinlog\fR
2565
can read binary log files and write new files containing the same content\(emthat is, in binary format rather than text format\&. This capability enables you to easily back up a binary log in its original format\&.
2566
\fBmysqlbinlog\fR
2567
can make a static backup, backing up a set of log files and stopping when the end of the last file is reached\&. It can also make a continuous (\(lqlive\(rq) backup, staying connected to the server when it reaches the end of the last log file and continuing to copy new events as they are generated\&. In continuous\-backup operation,
2568
\fBmysqlbinlog\fR
2569
runs until the connection ends (for example, when the server exits) or
2570
\fBmysqlbinlog\fR
2571
is forcibly terminated\&. When the connection ends,
2572
\fBmysqlbinlog\fR
2573
does not wait and retry the connection, unlike a slave replication server\&. To continue a live backup after the server has been restarted, you must also restart
2574
\fBmysqlbinlog\fR\&.
2575
.PP
2576
Binary log backup requires that you invoke
2577
\fBmysqlbinlog\fR
2578
with two options at minimum:
2579
.sp
2580
.RS 4
2581
.ie n \{\
2582
\h'-04'\(bu\h'+03'\c
2583
.\}
2584
.el \{\
2585
.sp -1
2586
.IP \(bu 2.3
2587
.\}
2588
The
2589
\fB\-\-read\-from\-remote\-server\fR
2590
(or
2591
\fB\-R\fR) option tells
2592
\fBmysqlbinlog\fR
2593
to connect to a server and request its binary log\&. (This is similar to a slave replication server connecting to its master server\&.)
2594
.RE
2595
.sp
2596
.RS 4
2597
.ie n \{\
2598
\h'-04'\(bu\h'+03'\c
2599
.\}
2600
.el \{\
2601
.sp -1
2602
.IP \(bu 2.3
2603
.\}
2604
The
2605
\fB\-\-raw\fR
2606
option tells
2607
\fBmysqlbinlog\fR
2608
to write raw (binary) output, not text output\&.
2609
.RE
2610
.PP
2611
Along with
2612
\fB\-\-read\-from\-remote\-server\fR, it is common to specify other options:
2613
\fB\-\-host\fR
2614
indicates where the server is running, and you may also need to specify connection options such as
2615
\fB\-\-user\fR
2616
and
2617
\fB\-\-password\fR\&.
2618
.PP
2619
Several other options are useful in conjunction with
2620
\fB\-\-raw\fR:
2621
.sp
2622
.RS 4
2623
.ie n \{\
2624
\h'-04'\(bu\h'+03'\c
2625
.\}
2626
.el \{\
2627
.sp -1
2628
.IP \(bu 2.3
2629
.\}
2630
\fB\-\-stop\-never\fR: Stay connected to the server after reaching the end of the last log file and continue to read new events\&.
2631
.RE
2632
.sp
2633
.RS 4
2634
.ie n \{\
2635
\h'-04'\(bu\h'+03'\c
2636
.\}
2637
.el \{\
2638
.sp -1
2639
.IP \(bu 2.3
2640
.\}
2641
\fB\-\-stop\-never\-slave\-server\-id=\fR\fB\fIid\fR\fR: The server ID that
2642
\fBmysqlbinlog\fR
2643
reports to the server when
2644
\fB\-\-stop\-never\fR
2645
is used\&. The default is 65535\&. This can be used to avoid a conflict with the ID of a slave server or another
2646
\fBmysqlbinlog\fR
2647
process\&. See
2648
the section called \(lqSPECIFYING THE MYSQLBINLOG SERVER ID\(rq\&.
2649
.RE
2650
.sp
2651
.RS 4
2652
.ie n \{\
2653
\h'-04'\(bu\h'+03'\c
2654
.\}
2655
.el \{\
2656
.sp -1
2657
.IP \(bu 2.3
2658
.\}
2659
\fB\-\-result\-file\fR: A prefix for output file names, as described later\&.
2660
.RE
2661
.PP
2662
To back up a server\*(Aqs binary log files with
2663
\fBmysqlbinlog\fR, you must specify file names that actually exist on the server\&. If you do not know the names, connect to the server and use the
2664
SHOW BINARY LOGS
2665
statement to see the current names\&. Suppose that the statement produces this output:
2666
.sp
2667
.if n \{\
2668
.RS 4
2669
.\}
2670
.nf
2671
mysql> \fBSHOW BINARY LOGS;\fR
2672
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
2673
| Log_name      | File_size |
2674
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
2675
| binlog\&.000130 |     27459 |
2676
| binlog\&.000131 |     13719 |
2677
| binlog\&.000132 |     43268 |
2678
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
2679
.fi
2680
.if n \{\
2681
.RE
2682
.\}
2683
.PP
2684
With that information, you can use
2685
\fBmysqlbinlog\fR
2686
to back up the binary log to the current directory as follows (enter each command on a single line):
2687
.sp
2688
.RS 4
2689
.ie n \{\
2690
\h'-04'\(bu\h'+03'\c
2691
.\}
2692
.el \{\
2693
.sp -1
2694
.IP \(bu 2.3
2695
.\}
2696
To make a static backup of
2697
binlog\&.000130
2698
through
2699
binlog\&.000132, use either of these commands:
2700
.sp
2701
.if n \{\
2702
.RS 4
2703
.\}
2704
.nf
2705
mysqlbinlog \-\-read\-from\-remote\-server \-\-host=\fIhost_name\fR \-\-raw
2706
  binlog\&.000130 binlog\&.000131 binlog\&.000132
2707
mysqlbinlog \-\-read\-from\-remote\-server \-\-host=\fIhost_name\fR \-\-raw
2708
  \-\-to\-last\-log binlog\&.000130
2709
.fi
2710
.if n \{\
2711
.RE
2712
.\}
2713
.sp
2714
The first command specifies every file name explicitly\&. The second names only the first file and uses
2715
\fB\-\-to\-last\-log\fR
2716
to read through the last\&. A difference between these commands is that if the server happens to open
2717
binlog\&.000133
2718
before
2719
\fBmysqlbinlog\fR
2720
reaches the end of
2721
binlog\&.000132, the first command will not read it, but the second command will\&.
2722
.RE
2723
.sp
2724
.RS 4
2725
.ie n \{\
2726
\h'-04'\(bu\h'+03'\c
2727
.\}
2728
.el \{\
2729
.sp -1
2730
.IP \(bu 2.3
2731
.\}
2732
To make a live backup in which
2733
\fBmysqlbinlog\fR
2734
starts with
2735
binlog\&.000130
2736
to copy existing log files, then stays connected to copy new events as the server generates them:
2737
.sp
2738
.if n \{\
2739
.RS 4
2740
.\}
2741
.nf
2742
mysqlbinlog \-\-read\-from\-remote\-server \-\-host=\fIhost_name\fR \-\-raw
2743
  \-\-stop\-never binlog\&.000130
2744
.fi
2745
.if n \{\
2746
.RE
2747
.\}
2748
.sp
2749
With
2750
\fB\-\-stop\-never\fR, it is not necessary to specify
2751
\fB\-\-to\-last\-log\fR
2752
to read to the last log file because that option is implied\&.
2753
.RE
1.2.3 by James Page
Import upstream version 5.6.19
2754
Output File Naming.PP
1 by James Page
Import upstream version 5.6.15
2755
Without
2756
\fB\-\-raw\fR,
2757
\fBmysqlbinlog\fR
2758
produces text output and the
2759
\fB\-\-result\-file\fR
2760
option, if given, specifies the name of the single file to which all output is written\&. With
2761
\fB\-\-raw\fR,
2762
\fBmysqlbinlog\fR
2763
writes one binary output file for each log file transferred from the server\&. By default,
2764
\fBmysqlbinlog\fR
2765
writes the files in the current directory with the same names as the original log files\&. To modify the output file names, use the
2766
\fB\-\-result\-file\fR
2767
option\&. In conjunction with
2768
\fB\-\-raw\fR, the
2769
\fB\-\-result\-file\fR
2770
option value is treated as a prefix that modifies the output file names\&.
2771
.PP
2772
Suppose that a server currently has binary log files named
2773
binlog\&.000999
2774
and up\&. If you use
2775
\fBmysqlbinlog \-\-raw\fR
2776
to back up the files, the
2777
\fB\-\-result\-file\fR
2778
option produces output file names as shown in the following table\&. You can write the files to a specific directory by beginning the
2779
\fB\-\-result\-file\fR
2780
value with the directory path\&. If the
2781
\fB\-\-result\-file\fR
2782
value consists only of a directory name, the value must end with the pathname separator character\&. Output files are overwritten if they exist\&.
2783
.TS
2784
allbox tab(:);
2785
lB lB.
2786
T{
2787
\fB\-\-result\-file\fR Option
2788
T}:T{
2789
Output File Names
2790
T}
2791
.T&
2792
l l
2793
l l
2794
l l.
2795
T{
2796
\fB\-\-result\-file=x\fR
2797
T}:T{
2798
xbinlog\&.000999 and up
2799
T}
2800
T{
2801
\fB\-\-result\-file=/tmp/\fR
2802
T}:T{
2803
/tmp/binlog\&.000999 and up
2804
T}
2805
T{
2806
\fB\-\-result\-file=/tmp/x\fR
2807
T}:T{
2808
/tmp/xbinlog\&.000999 and up
2809
T}
2810
.TE
2811
.sp 1
1.2.4 by Robie Basak
Import upstream version 5.6.23
2812
Example: mysqldump + mysqlbinlog for Backup and Restore.PP
1 by James Page
Import upstream version 5.6.15
2813
The following example describes a simple scenario that shows how to use
2814
\fBmysqldump\fR
2815
and
2816
\fBmysqlbinlog\fR
2817
together to back up a server\*(Aqs data and binary log, and how to use the backup to restore the server if data loss occurs\&. The example assumes that the server is running on host
2818
\fIhost_name\fR
2819
and its first binary log file is named
2820
binlog\&.000999\&. Enter each command on a single line\&.
2821
.PP
2822
Use
2823
\fBmysqlbinlog\fR
2824
to make a continuous backup of the binary log:
2825
.sp
2826
.if n \{\
2827
.RS 4
2828
.\}
2829
.nf
2830
mysqlbinlog \-\-read\-from\-remote\-server \-\-host=\fIhost_name\fR \-\-raw
2831
  \-\-stop\-never binlog\&.000999
2832
.fi
2833
.if n \{\
2834
.RE
2835
.\}
2836
.PP
2837
Use
2838
\fBmysqldump\fR
2839
to create a dump file as a snapshot of the server\*(Aqs data\&. Use
2840
\fB\-\-all\-databases\fR,
2841
\fB\-\-events\fR, and
2842
\fB\-\-routines\fR
2843
to back up all data, and
2844
\fB\-\-master\-data=2\fR
2845
to include the current binary log coordinates in the dump file\&.
2846
.sp
2847
.if n \{\
2848
.RS 4
2849
.\}
2850
.nf
2851
mysqldump \-\-host=\fIhost_name\fR \-\-all\-databases \-\-events \-\-routines \-\-master\-data=2> \fIdump_file\fR
2852
.fi
2853
.if n \{\
2854
.RE
2855
.\}
2856
.PP
2857
Execute the
2858
\fBmysqldump\fR
2859
command periodically to create newer snapshots as desired\&.
2860
.PP
2861
If data loss occurs (for example, if the server crashes), use the most recent dump file to restore the data:
2862
.sp
2863
.if n \{\
2864
.RS 4
2865
.\}
2866
.nf
2867
mysql \-\-host=\fIhost_name\fR \-u root \-p < \fIdump_file\fR
2868
.fi
2869
.if n \{\
2870
.RE
2871
.\}
2872
.PP
2873
Then use the binary log backup to re\-execute events that were written after the coordinates listed in the dump file\&. Suppose that the coordinates in the file look like this:
2874
.sp
2875
.if n \{\
2876
.RS 4
2877
.\}
2878
.nf
2879
\-\- CHANGE MASTER TO MASTER_LOG_FILE=\*(Aqbinlog\&.001002\*(Aq, MASTER_LOG_POS=27284;
2880
.fi
2881
.if n \{\
2882
.RE
2883
.\}
2884
.PP
2885
If the most recent backed\-up log file is named
2886
binlog\&.001004, re\-execute the log events like this:
2887
.sp
2888
.if n \{\
2889
.RS 4
2890
.\}
2891
.nf
2892
mysqlbinlog \-\-start\-position=27284 binlog\&.001002 binlog\&.001003 binlog\&.001004
2893
  | mysql \-\-host=\fIhost_name\fR \-u root \-p
2894
.fi
2895
.if n \{\
2896
.RE
2897
.\}
2898
.PP
2899
You might find it easier to copy the backup files (dump file and binary log files) to the server host to make it easier to perform the restore operation, or if MySQL does not allow remote
2900
root
2901
access\&.
2902
.SH "SPECIFYING THE MYSQLBINLOG SERVER ID"
2903
.PP
2904
When invoked with the
2905
\fB\-\-read\-from\-remote\-server\fR
2906
option,
2907
\fBmysqlbinlog\fR
2908
connects to a MySQL server, specifies a server ID to identify itself, and requests binary log files from the server\&. You can use
2909
\fBmysqlbinlog\fR
2910
to request log files from a server in several ways:
2911
.sp
2912
.RS 4
2913
.ie n \{\
2914
\h'-04'\(bu\h'+03'\c
2915
.\}
2916
.el \{\
2917
.sp -1
2918
.IP \(bu 2.3
2919
.\}
2920
Specify an explicitly named set of files: For each file,
2921
\fBmysqlbinlog\fR
2922
connects and issues a
2923
Binlog dump
2924
command\&. The server sends the file and disconnects\&. There is one connection per file\&.
2925
.RE
2926
.sp
2927
.RS 4
2928
.ie n \{\
2929
\h'-04'\(bu\h'+03'\c
2930
.\}
2931
.el \{\
2932
.sp -1
2933
.IP \(bu 2.3
2934
.\}
2935
Specify the beginning file and
2936
\fB\-\-to\-last\-log\fR:
2937
\fBmysqlbinlog\fR
2938
connects and issues a
2939
Binlog dump
2940
command for all files\&. The server sends all files and disconnects\&.
2941
.RE
2942
.sp
2943
.RS 4
2944
.ie n \{\
2945
\h'-04'\(bu\h'+03'\c
2946
.\}
2947
.el \{\
2948
.sp -1
2949
.IP \(bu 2.3
2950
.\}
2951
Specify the beginning file and
2952
\fB\-\-stop\-never\fR
2953
(which implies
2954
\fB\-\-to\-last\-log\fR):
2955
\fBmysqlbinlog\fR
2956
connects and issues a
2957
Binlog dump
2958
command for all files\&. The server sends all files, but does not disconnect after sending the last one\&.
2959
.RE
2960
.PP
2961
With
2962
\fB\-\-read\-from\-remote\-server\fR
2963
only,
2964
\fBmysqlbinlog\fR
2965
connects using a server ID of 0, which tells the server to disconnect after sending the last requested log file\&.
2966
.PP
2967
With
2968
\fB\-\-read\-from\-remote\-server\fR
2969
and
2970
\fB\-\-stop\-never\fR,
2971
\fBmysqlbinlog\fR
2972
connects using a nonzero server ID, so the server does not disconnect after sending the last log file\&. The server ID is 65535 by default, but this can be changed with
2973
\fB\-\-stop\-never\-slave\-server\-id\fR\&.
2974
.PP
2975
Thus, for the first two ways of requesting files, the server disconnects because
2976
\fBmysqlbinlog\fR
2977
specifies a server ID of 0\&. It does not disconnect if
2978
\fB\-\-stop\-never\fR
2979
is given because
2980
\fBmysqlbinlog\fR
2981
specifies a nonzero server ID\&.
2982
.SH "COPYRIGHT"
2983
.br
2984
.PP
1.2.4 by Robie Basak
Import upstream version 5.6.23
2985
Copyright \(co 1997, 2015, Oracle and/or its affiliates. All rights reserved.
1 by James Page
Import upstream version 5.6.15
2986
.PP
2987
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
2988
.PP
2989
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
2990
.PP
2991
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
2992
.sp
2993
.SH "NOTES"
2994
.IP " 1." 4
2995
MySQL Internals: The Binary Log
2996
.RS 4
2997
\%http://dev.mysql.com/doc/internals/en/binary-log.html
2998
.RE
2999
.SH "SEE ALSO"
3000
For more information, please refer to the MySQL Reference Manual,
3001
which may already be installed locally and which is also available
3002
online at http://dev.mysql.com/doc/.
3003
.SH AUTHOR
3004
Oracle Corporation (http://dev.mysql.com/).