Mysqlbinlog (log management tool)

Source: Internet
Author: User
Tags crc32

Mysqlbinlog is used to process binary log files, and if you want to view the text content of these log files, you need to use the Mysqlbinlog tool.

1.mysqlbinlogSyntax of the command
Shell > Mysqlbinlog [options] logfile1 logfile2 ...
2. mysqlbinlogThe options
-D,--database=name      displays only the dump content for the specified database. -O,--offset=#           skips the first n rows of log entries. -R,--result-file=name to dump the   input text format file to the specified file. -S,--short-form         uses a simple format. --set-charset=name       Add ' set NAMES character_set ' statement at the beginning of the dump file. --start-datetime=name    The start time of the dump log. --stop-datetime=name     the cutoff time for the dump log. -j,   the starting position of the--start-position=# dump log. --stop-position=#        the cutoff location for the dump log.
3. Example

View the location of the binary log file in the following way:

Mysql> Show variables like '%log% '; +-----------------------------------------+--------------------------------- -----------+.... Omit .... | Log_bin                                 | OFF                                        | | log_bin_basename                        |                                            | | log_bin_index | | | |                                            log_bin_trust_function_creators         | OFF                                        | | log_bin_use_v1_row_events               | OFF                                        | .... Omit .... +-----------------------------------------+--------------------------------------------+

The above output is visible, the value of Log-bin is off, so you must first open Log-bin, as follows:

VI/ETC/MY.CNF[MYSQLD] .... Omit .... log-bin=bin-log   # After the equals sign prefix for the name of the Log-bin file, the name can be customized.

Dump Log-bin:

mysql> use test; Reading table information for completion of table and column namesyou can turn off this feature to get a quicker startup W Ith-adatabase changedmysql> truncate TABLE t1; Query OK, 0 rows Affected (0.00 sec) mysql> insert into T1 values (214); Query OK, 1 row Affected (0.00 sec) mysql> insert into T1 values (215); Query OK, 1 row Affected (0.00 sec)
--------------------------------------------------------------------------------------------------------------- ------
# Mysqlbinlog bin-log.000002 .... Omit .... Use ' Test '/*!*/; Omit .... truncate table t1/*!*/;# at 211#160830 7:28:36 Server ID 1 end_log_pos 290 CRC32 0x1f3368bb Query thread_id=1 Exec_time=0 Error_code=0set timestamp=1472513316/*!*/; begin/*!*/;# at 290#160830 7:28:36 server ID 1 end_log_pos 390 CRC32 0xcf40a797 Query thread_id=1 exec_time=0 Error_code=0set Timestamp=1472513316/*!*/;insert to T1 values (214)/*!*/;# at 390#160830 7:28:36 Server ID 1 end_log_p OS 421 CRC32 0x9d9f8407 Xid = 11commit/*!*/;# at 421#160830 7:28:48 server ID 1 end_log_pos CRC32 0x722de8f9 Query Thread_id=1 exec_time=0 Error_code=0set timestamp=1472513328/*!*/; begin/*!*/;# at 500#160830 7:28:48 Server ID 1 end_log_pos 601 CRC32 0x03e2087d Query thread_id=1 exec_time=0 Error_code=0set Timestamp=1472513328/*!*/;insert to T1 values (215)/*!*/;# at 601#160830 7:28:48 Server ID 1 end_log_ POS 632 CRC32 0x062775e4 Xid = 12commit/*!*/;D elimiter; # End of Log fiLe+

Mysqlbinlog (log management tool)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.