mysqlbinlog使用

版本號:MySQLbinlog Ver 3.4 for linux-glibc2.5 at x86_64

公司主營業(yè)務(wù):做網(wǎng)站、網(wǎng)站建設(shè)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。成都創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)公司推出福清免費做網(wǎng)站回饋大家。

 

使用方式:mysqlbinlog --option --option --option .. mysqlbinlog.00001 mysqlbinlog.00002....

Usage: mysqlbinlog [options] log-files

  -?, --help          Display this help and exit.

  --base64-output=name 當(dāng)日志格式為row模式時,需要加此參數(shù)轉(zhuǎn)義,才能看得懂,

                       注意:此選項只是用于查看,排查等,真正恢復(fù)數(shù)據(jù)時不可加此參數(shù)


                       一般和 -vv配合使用

  --bind-address=name IP address to bind to.

  --character-sets-dir=name 

                      Directory for character set files.

  -d, --database=name List entries for just this database (local log only).

  --debug-check       Check memory and open file usage at exit .

  --debug-info        Print some debug info at exit.

  --default-auth=name Default authentication client-side plugin to use.

  -D, --disable-log-bin 

                      Disable binary log. This is useful, if you enabled

                      --to-last-log and are sending the output to the same

                      MySQL server. This way you could avoid an endless loop.

                      You would also like to use it when restoring after a

                      crash to avoid duplication of the statements you already

                      have. NOTE: you will need a SUPER privilege to use this

                      option.

  -F, --force-if-open Force if binlog was not closed properly.

                      (Defaults to on; use --skip-force-if-open to disable.)

  -f, --force-read    Force reading unknown binlog events.

  -H, --hexdump       Augment output with hexadecimal and ASCII event dump.

  -h, --host=name     Get the binlog from server.

  -l, --local-load=name 

                      Prepare local temporary files for LOAD DATA INFILE in the

                      specified directory.

  -o, --offset=#      Skip the first N entries.

  -p, --password[=name] 

                      Password to connect to remote server.

  --plugin-dir=name   Directory for client-side plugins.

  -P, --port=#        Port number to use for connection or 0 for default to, in

                      order of preference, my.cnf, $MYSQL_TCP_PORT,

                      /etc/services, built-in default (3306).

  --protocol=name     The protocol to use for connection (tcp, socket, pipe,

                      memory).

  -R, --read-from-remote-server 從遠(yuǎn)程服務(wù)器讀取binlog信息,不加此選項,一切 -h -u -p 等等遠(yuǎn)程連接選項都被忽略,將變成從本地讀取那一堆你自己定義的mysql-binlog......

                      Read binary logs from a MySQL server. This is an alias

                      for read-from-remote-master=BINLOG-DUMP-NON-GTIDS.

  --read-from-remote-master=name 

                      Read binary logs from a MySQL server through the

                      COM_BINLOG_DUMP or COM_BINLOG_DUMP_GTID commands by

                      setting the option to either BINLOG-DUMP-NON-GTIDS or

                      BINLOG-DUMP-GTIDS, respectively. If

                      --read-from-remote-master=BINLOG-DUMP-GTIDS is combined

                      with --exclude-gtids, transactions can be filtered out on

                      the master avoiding unnecessary network traffic.

  --raw               Requires -R.

                      當(dāng)遠(yuǎn)程備份binlog時需要開啟,生成二進(jìn)制文件Output raw binlog data instead of SQL

                      statements, output is to log files.

  -r, --result-file=name 

                      當(dāng)遠(yuǎn)程備份時,指定備份于本地的目錄

                      /backup/mysql-bin

                      Direct output to a given file. With --raw this is a

                      prefix for the file names.

  --secure-auth       Refuse client connecting to server if it uses old

                      (pre-4.1.1) protocol.

                      (Defaults to on; use --skip-secure-auth to disable.)

  --server-id=#       Extract only binlog entries created by the server having

                      the given id.

  --server-id-bits=#  Set number of significant bits in server-id

  --set-charset=name  Add 'SET NAMES character_set' to the output.

  -s, --short-form    Just show regular queries: no extra info and no row-based

                      events. This is for testing only, and should not be used

                      in production systems. If you want to suppress

                      base64-output, consider using --base64-output=never

                      instead.

  -S, --socket=name   The socket file to use for connection.

  --start-datetime=name 

                      開始時間點,從指定的第一個文件開始掃描,》=這個時間點的日志

                      Start reading the binlog at first event having a datetime

                      equal or posterior to the argument; the argument must be

                      a date and time in the local time zone, in any format

                      accepted by the MySQL server for DATETIME and TIMESTAMP

                      types, for example: 2004-12-25 11:25:56 (you should

                      probably use quotes for your shell to set it properly).

  -j, --start-position=# 

                      開始pos點,第一個binlog文件的pos點

                      Start reading the binlog at position N. Applies to the

                      first binlog passed on the command line.

  --stop-datetime=name 

                      終止時間點

                      Stop reading the binlog at first event having a datetime

                      equal or posterior to the argument; the argument must be

                      a date and time in the local time zone, in any format

                      accepted by the MySQL server for DATETIME and TIMESTAMP

                      types, for example: 2004-12-25 11:25:56 (you should

                      probably use quotes for your shell to set it properly).

  --stop-never        用于遠(yuǎn)程備份binlog

                      Wait for more data from the server instead of stopping at

                      the end of the last log. Implicitly sets --to-last-log

                      but instead of stopping at the end of the last log it

                      continues to wait till the server disconnects.

  --stop-never-slave-server-id=# 

                      The slave server_id used for --read-from-remote-server

                      --stop-never.

  --stop-position=#   最后一個指定的文件pos點

                      Stop reading the binlog at position N. Applies to the

                      last binlog passed on the command line.

  -t, --to-last-log   

                      源于遠(yuǎn)程備份或者,將遠(yuǎn)程服務(wù)器的binlog下載到本地,此參數(shù)代表終點 binlog file ,如 mysql-binlog.00234 

                      Requires -R. Will not stop at the end of the requested

                      binlog but rather continue printing until the end of the

                      last binlog of the MySQL server. If you send the output

                      to the same MySQL server, that may lead to an endless

                      loop.

  -u, --user=name     Connect to the remote server as username.

  -v, --verbose       Reconstruct pseudo-SQL statements out of row events. -v

                      -v adds comments on column data types.

  -V, --version       Print version and exit.

  --open-files-limit=# 

                      Used to reserve file descriptors for use by this program.

  -c, --verify-binlog-checksum 

                      Verify checksum binlog events.

  --binlog-row-event-max-size=# 

                      The maximum size of a row-based binary log event in

                      bytes. Rows will be grouped into events smaller than this

                      size if possible. This value must be a multiple of 256.

  --skip-gtids        

                      

                      Do not print Global Transaction Identifier information

                      (SET GTID_NEXT=... etc).

  --include-gtids=name 

                      Print events whose Global Transaction Identifiers were

                      provided.

  --exclude-gtids=name 

                      Print all events but those whose Global Transaction

                      Identifiers were provided.

Variables (--variable-name=value)

and boolean options {FALSE|TRUE}  Value (after reading options)

--------------------------------- ----------------------------------------

base64-output                     (No default value)

bind-address                      (No default value)

character-sets-dir                (No default value)

database                          (No default value)

debug-check                       FALSE

debug-info                        FALSE

default-auth                      (No default value)

disable-log-bin                   FALSE

force-if-open                     TRUE

force-read                        FALSE

hexdump                           FALSE

host                              (No default value)

local-load                        (No default value)

offset                            0

plugin-dir                        (No default value)

port                              0

read-from-remote-server           FALSE

read-from-remote-master           (No default value)

raw                               FALSE

result-file                       (No default value)

secure-auth                       TRUE

server-id                         0

server-id-bits                    32

set-charset                       (No default value)

short-form                        FALSE

socket                            /tmp/mysql.sock

start-datetime                    (No default value)

start-position                    4

stop-datetime                     (No default value)

stop-never                        FALSE

stop-never-slave-server-id        -1

stop-position                     18446744073709551615

to-last-log                       FALSE

user                              (No default value)

open-files-limit                  64

verify-binlog-checksum            FALSE

binlog-row-event-max-size         4294967040

skip-gtids                        FALSE

include-gtids                     (No default value)

exclude-gtids                     (No default value)

示例:

1、從遠(yuǎn)程服務(wù)器 讀取 數(shù)據(jù)庫test 開始時間 2017-09-26 12:05:00' 的binlog

mysqlbinlog -uroot -p123456 -h292.168.1.100 -R -d test   --start-datetime='2017-09-26 12:05:00' --base64-output=decode-rows -vv mysql-binlog.000004 mysql-binlog.000004 | more

2、從遠(yuǎn)程服務(wù)器同步binlog

mysqlbinlog -uroot -p123456 -h292.168.1.100 -R --raw --stop-never -r mysql mysql-binlog.000001

如果是mysql服務(wù)器上執(zhí)行,可以去除 -uroot -p123456 -h292.168.1.100 -R

新聞標(biāo)題:mysqlbinlog使用
網(wǎng)頁路徑:http://muchs.cn/article10/ghhjgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、微信小程序服務(wù)器托管、虛擬主機(jī)網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化