Oracle 5.0 Reference Manual page 368

Table of Contents

Advertisement

mysqlbinlog
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
[347]
option (to be able to say, for example, "roll forward my databases to how they were
datetime
today at 10:30 a.m.").
If you have more than one binary log to execute on the MySQL server, the safe method is to process
them all using a single connection to the server. Here is an example that demonstrates what may be
unsafe:
shell>
mysqlbinlog binlog.000001 | mysql -u root -p # DANGER!!
shell>
mysqlbinlog binlog.000002 | mysql -u root -p # DANGER!!
Processing binary logs this way using multiple connections to the server causes problems if the first log
file contains a
CREATE TEMPORARY TABLE
uses the temporary table. When the first
table. When the second
To avoid problems like this, use a single
you want to process. Here is one way to do so:
shell>
mysqlbinlog binlog.000001 binlog.000002 | mysql -u root -p
Another approach is to write all the logs to a single file and then process the file:
shell>
mysqlbinlog binlog.000001 >
shell>
mysqlbinlog binlog.000002 >> /tmp/statements.sql
shell>
mysql -u root -p -e "source /tmp/statements.sql"
can produce output that reproduces a
mysqlbinlog
original data file.
mysqlbinlog
statement that refers to the file. The default location of the directory where these files are
INFILE
written is system-specific. To specify a directory explicitly, use the
Because
mysqlbinlog
statements (that is, it adds LOCAL), both the client and the server that you use to process the
statements must be configured with the
with
LOAD DATA
LOCAL".
Warning
The temporary files created for
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 original_file_name-#-#.
The
[345]
--hexdump
shell>
mysqlbinlog --hexdump master-bin.000001
The hex output consists of comment lines beginning with #, so the output might look like this for the
preceding command:
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
# at 4
#051024 17:24:13 server id 1
# Position
Timestamp
# 00000004 9d fc 5c 43
# 00000017 04 00 35 2e 30 2e 31 35
# 00000027 6f 67 00 00 00 00 00 00
# 00000037 00 00 00 00 00 00 00 00
# 00000047 00 00 00 00 9d fc 5c 43
— Utility for Processing Binary Log Files
statement and the second log contains a statement that
mysql
process attempts to use the table, the server reports "unknown table."
mysql
mysql
/tmp/statements.sql
copies the data to a temporary file and writes a
converts
LOAD DATA INFILE
LOCAL
option produces a hex dump of the log contents:
end_log_pos 98
Type
Master ID
0f
01 00 00 00
2d 64 65 62 75 67 2d 6c |..5.0.15.debug.l|
00 00 00 00 00 00 00 00 |og..............|
00 00 00 00 00 00 00 00 |................|
13 38 0d 00 08 00 12 00 |.......C.8......|
348
process terminates, the server drops the temporary
process to execute the contents of all binary logs that
LOAD DATA INFILE
--local-load
statements to
capability enabled. See
LOAD DATA LOCAL
Size
Master Pos
5e 00 00 00
62 00 00 00
--stop-
operation without the
LOAD DATA LOCAL
[345]
option.
LOAD DATA LOCAL INFILE
Section 6.1.6, "Security Issues
statements are not
Flags
00 00

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents