This MySQL statement displays the events in a binary log file.
hits past month: 6 ; last updated: may 4, 2009 - 2:34am ; parent: MySQL ReplicationSHOW BINLOG EVENTS [IN 'log_filename'] [FROM position] [LIMIT [offset,] count]
This MySQL statement displays the events in a binary log file—it's used with replication. Use the IN clause to specify a particular log file. If the IN clause is omitted, the current file is used. To obtain a list of binary log files, use the MySQL statement, SHOW MASTER LOGS.
Here is an example of how you can use this MySQL statement and typical results:
SHOW BINLOG EVENTS IN 'log-bin.000161' \G
*************************** 1. row ***************************
Log_name: log-bin.000161
Pos: 4
Event_type: Start
Server_id: 1
Orig_log_pos: 4
Info: Server ver: 4.1.7-standard-log, Binlog ver: 3
1 row in set (0.00 sec)
This log file has only one row of data, because the MySQL statement was run shortly after the server was started. For a larger log file recording many rows of events, the results take a long time and drain system resources, significantly. To minimize this you can focus and limit the results with the FROM and LIMIT clauses. In the results, notice the Pos label with a value of 4. In a large log file, that number might be in the thousands. The results displayed could be focused only on rows starting from a particular position in the log with the FROM clause. You can limit the number of rows of events displayed with the LIMIT clause. In the LIMIT clause, you can also set the starting point of the output based on the number of rows in the results set and limit them to a certain number of rows. Here is an example of both of these clauses:
SHOW BINLOG EVENTS IN 'log-bin.000160'
FROM 3869 LIMIT 2,1 \G
*************************** 1. row ***************************
Log_name: log-bin.000160
Pos: 4002
Event_type: Intvar
Server_id: 1
Orig_log_pos: 4002
Info: INSERT_ID=5
In this example, the retrieval of log events is to begin from position 3869 because of the FROM clause. The results set contains several rows, although only one is shown here. The display is limited to one row, starting from the third one in the results set per the LIMIT clause. The number of skipped records si the sum of the FROM argument and the first LIMIT argument.
As an alternative to using this MySQL statement when working with large binary log files, you might try using the mysqlbinlog utility and redirecting the results to a text file that you can read in a text editor when it's finished. Besides, this utility will provide you more information than SHOW BINLOG EVENTS.