Use syntax
mysqlbinlog [options] log-files
Description of common parameters
parameter | describe |
---|---|
-?, --help | Help information |
--base64-output=name | Output format: 'auto': Auto by default‘ never ': output in binlog event format‘ Decode rows': output pseudo SQL in annotation mode |
-d, --database=name | List only entries for this database (only local logs) |
--bind-address | Bound IP address |
-h, --host=name | Get the binary log of mysql server of the given host |
-p, --password[=name] | Password for connection |
-u, --user | User connecting to remote server |
-P, --port= | port |
-R, --read-from-remote-server | Read binary log from MySQL server |
--raw | Used with - R to output the original binlog log data |
--start-datetime=name | Start time of parsing log |
--stop-datetime=name | End time of parsing log |
-j, --start-position | Starting point of parsing log |
--stop-position= | Parse log end point |
-v, --verbose | detailed information |
-f, --force-read | Force to continue reading. If an unrecognized event occurs, a warning message will be output |
-o, --offset=N | Skip the first N entries |
-s, --short-form | Only the statements contained in the log are displayed, and no other information is displayed |
--character-sets-dir=name | Character set path information |
-S, --socket=name | socket |
-D, --disable-log-bin | Disable binary If you use the - to last logs option to send the output to the same mysql server, you can avoid infinite loops. This option is also useful in crash recovery to avoid copying recorded statements. super requires this option. |
-t, --to-last-log | In the mysql server, the end of the requested binary log does not stop, but continues to print until the end of the last binary log. If the output is sent to the same mysql server, it will cause an infinite loop. This option should be -- read from remote server |
-F, --force-if-open | It is enabled by default. If binlog is not closed correctly, it is forced to be closed |
--connection-server-id | Server ID of the slave Library |
-H, --hexdump | Displays hexadecimal and ASCII event dumps in comments |
-l, --local-load=name | The directory specified in the file to prepare the local temporary file for LOAD DATA INFILE |
--skip-gtids | Skip GTID |
--include-gtids=name | GTID provided by print time |
--exclude-gtids=name | Print the GTID provided for everything |
--print-table-metadata | Print stored in table_ map_ log_ metadata information of event |
Example test
## binlog log file parsing mysqlbinlog --base64-output=decode-row /data/mysql_log/mysql-bin.000008 -v ## Resolve the specified time mysqlbinlog --base64-output=decode-row /data/mysql_log/mysql-bin.000008 -v --start-datetime='2022-03-02 14:30:30' ## Analytic point mysqlbinlog --base64-output=decode-row /data/mysql_log/mysql-bin.000008 -v --start-position=6199 --stop-position=6319
## Parsed file information format ... .... SET TIMESTAMP=1646202630/*!*/; BEGIN /*!*/; # at 6199 #220302 14:30:30 server id 1033306 end_log_pos 6248 CRC32 0x56411c87 Table_map: `test`.`bb` mapped to number 114 # at 6248 #220302 14:30:30 server id 1033306 end_log_pos 6319 CRC32 0xeb502b34 Write_rows: table id 114 flags: STMT_END_F ### INSERT INTO `test`.`bb` ### SET ### @1=1 ### @2=16 ### INSERT INTO `test`.`bb` ### SET ### @1=2 ### @2=17 ### INSERT INTO `test`.`bb` ### SET ### @1=3 ### @2=18 ### INSERT INTO `test`.`bb` ### SET ### @1=4 ### @2=20 # at 6319 #220302 14:30:30 server id 1033306 end_log_pos 6350 CRC32 0x9fd4e6c5 Xid = 831 COMMIT/*!*/;