How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog如何阅读MySQL的二进制日志文件( binlog )与mysqlbinlog

MySQL database server generates binary log files for every transaction to the databases, provided administrator does not disable or comment out the “log-bin” parameter in my.cny configuration file. MySQL数据库服务器生成的二进制日志文件为每交易数据库,提供了管理员没有禁用或评论,指出“在本机登录斌”参数在my.cny配置文件。 The binary log files are written in binary format.二进制日志文件都写的二进制格式。 Although the binary logs, or also known as logbin are mainly used for MySQL database replication purpose, sometimes you may need to examine or read the contents of binary logs in text format, where the mysqlbinlog utility will come in handy.虽然二进制日志,或者也称为logbin主要用于MySQL数据库复制的目的,但有时,你可能需要检查或阅读的内容二进制日志以文本格式,如mysqlbinlog实用工具能派上用场。

Binary log file, which normally has name with the format host_name-bin.xxxxxx and store in /var/lib/mysql directory, could not be opened and read straight away as it’s in unreadable binary format.二进制日志文件,该文件通常名称与格式host_name - bin.xxxxxx和商店,到/ var / lib / MySQL的目录,无法打开,并宣读了直线距离,因为它的在不可读的二进制格式。 To read the binary logs in text format, we can make use of mysqlbinlog command, which also able to readrelay log files written by a slave server in a replication setup.阅读二进制日志以文本格式,我们可以利用mysqlbinlog命令,该命令也能readrelay日志文件的书面由一个奴隶的服务器在复制设置。 Relay logs have the same format as binary log files.中继日志中有相同的格式,作为二进制日志文件。

To use mysqlbinlog utility is simple, simply use the following command syntax to invoke mysqlbinlog after login in as root (else you have to specify user name and password) to shell via SSH:使用mysqlbinlog实用工具很简单,只需使用下列命令语法引用mysqlbinlog登录后,在作为根(否则,你必须指定的用户名和密码)壳牌通过SSH :

mysqlbinlog [options] log_file … mysqlbinlog [选项] log_file …

So to read and display the contents of the binary log file named binlog.000001, use this command:因此,读取和显示的内容,该二进制日志文件,名为binlog.000001 ,使用这个命令:

mysqlbinlog binlog.000001 mysqlbinlog binlog.000001

The binary log files and its data are likely to be very huge, thus making it almost impossible to read anything on screen.二进制日志文件和数据,可能会非常庞大,从而使这几乎是不可能的阅读任何在屏幕上。 However, you can pipe the output of mysqlbinlog into a file which can be open up for later browsing in text editor, by using the following command:不过,您可以管的输出mysqlbinlog到档案中可开放供以后浏览,在文本编辑器,通过使用以下命令:

mysqlbinlog binlog.000001 > filename.txt mysqlbinlog binlog.000001 > filename.txt

To reduce the amount of data retrieved from binary logs, there are several options that can be used to limit the data that is been returned.减少的数据量来自二进制日志,有几个选项可以用来限制数据是被退回。 Among the useful ones are listed below:其中有用的列举如下:

–start-datetime=datetime -启动日期时间=日期时间

Start reading the binary log at the first event having a timestamp equal to or later than the datetime argument.开始阅读该二进制日志在第一次事件有一个时间戳记相等于或不迟于该日期时间的说法。 The datetime value is relative to the local time zone on the machine where you run mysqlbinlog.该日期时间价值是相对的,以当地时区的计算机上运行的地方,你mysqlbinlog 。 The value should be in a format accepted for the DATETIME or TIMESTAMP data types.该值应在格式接纳为日期时间或时间戳的数据类型。 For example:例如:

mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000001 mysqlbinlog -启动日期时间= “ 2 005年1 2月2 5日1 1时2 5分5 6秒” b inlog.000001

–stop-datetime=datetime 一站式日期时间=日期时间

Stop reading the binary log at the first event having a timestamp equal or posterior to the datetime argument.停止读二进制日志在第一次事件有一个时间戳等于或后向日期时间的说法。 This option is useful for point-in-time recovery.这个选项是有益的时间点复苏。 See the description of the –start-datetime option for information about the datetime value.见描述-开始日期时间的选择有关日期时间的价值。

–start-position=N 启动位置为N

Start reading the binary log at the first event having a position equal to the N argument.开始阅读该二进制日志在第一次事件有一个平等的地位,以氮的论据。 This option applies to the first log file named on the command line.这个选项适用于第一个日志文件命名的命令行。

–stop-position=N 一站式服务的立场,为N

Stop reading the binary log at the first event having a position equal or greater than the N argument.停止读二进制日志在第一次事件有一个平等的地位或大于氮的论据。 This option applies to the last log file named on the command line.这个选项适用于过去的日志文件命名的命令行。

For more usage information on mysqlbinlog, visit有关更多用法信息对mysqlbinlog ,请访问 here这里 .

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明 :这是一个机器翻译网页是“按原样”提供的担保。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原版的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at分享和贡献,或取得技术的支持和帮助,在 My Digital Life Forums 我的数字生活论坛 .



One Response to “How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog” 1回应“如何阅读MySQL的二进制日志文件( binlog )与mysqlbinlog ”

  1. Pisu pisu
    June 29th, 2008 16:33 2008年6月29日16时33分
    1

    This post saved my life today… when the binary log were the only way to retrieve important data get lost… thanks!!这个职位救了我的生活…今天,当二进制日志人的唯一途径检索的重要数据丢失…感谢!

Leave a Reply离开的答复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签:的<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <删除日期时间= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅无评论


Custom Search

New Articles新的条款,

Incoming Search Terms for the Article传入的搜索条件文章

mysqlbinlog mysqlbinlog - - BINLOG binlog - - mysql binary log MySQL的二进制日志 - - mysql binlogs MySQL的binlogs - - mysql logs MySQL的日志 - - read mysql logs 阅读MySQL的日志 - - mysql log reader MySQL的记录读取器 - - mysql log file MySQL的日志文件 - - how to read mysql log 如何阅读MySQL的日志 - - mysql log files MySQL的日志文件 - - mysql read bin log MySQL的阅读斌日志 - - read mysql log 阅读MySQL的日志 - - mysql binary logs MySQL的二进制日志 - - mysql log read MySQL的日志阅读 - - reading mysql logs 读MySQL的日志 - - mysql binary log reader MySQL的二进制日志读者 - - mysql binlog format MySQL的binlog格式 - - mysql binlog MySQL的binlog - - mysql bin log reader MySQL的本日志的读者 - - binlog mysql binlog的MySQL - - mysqlbinlog example mysqlbinlog的例子 - - mysql read log MySQL的阅读日志 - - read mysql bin log 阅读的MySQL斌日志 - - binary log 二进制日志 - - read binlog 阅读binlog - - mysql binary log files MySQL的二进制日志文件 - - mysql binary logging MySQL的二进制日志记录 - - mysqlbinlog usage mysqlbinlog使用 - - mysql binary log format MySQL的二进制日志格式 - - mysql bin log export MySQL的斌原木出口 - - binlogs in mysql binlogs在MySQL - - mysql log format MySQL的日志格式 - - how to read mysql bin log 如何阅读的MySQL斌日志 - - mysql logging MySQL的测井 - - mysql binlog reader MySQL的binlog读者 - - mysql binary log location MySQL的二进制日志位置 - - mysql log files windows MySQL的日志文件的Windows - - mysql bin log MySQL的斌日志 - - reading mysql bin logs 读的MySQL斌日志 - - mysql read logs MySQL的阅读日志 - - mysql binary MySQL的二进制 - - tool read mysql binlog file 工具阅读MySQL的binlog文件 - - mysqlbinlog windows mysqlbinlog的Windows - - logs mysql MySQL的日志 - - change binlog position 改变binlog的立场 - - mysql bin read MySQL的斌阅读 - - windows mysql binary logs commands 在Windows MySQL的二进制日志命令 - - binlogs mysql binlogs的MySQL - - restore binlog mysql windows 恢复binlog的MySQL的Windows - - binlog binlog - -