拿本机的mysql做测试
语句:
mysqlbinlog -uroot -proot -h127.0.0.1 -P3306 --read-from-remote-server mysql-bin.000001 --base64-output=decode-rows -v > 1
-u 用户名
-p 密码
-h 远程mysql实例host
- P 端口
--read-from-remote-server -R
从MySQL服务器读二进制日志。如果未给出该选项,任何连接参数选项将被忽略。
--base64-output=decode-rows
表示解析row模式的binlog(二进制)为可读的文本
-v 参数的解释,引用http://blog.csdn.net/zyz511919766/article/details/38089393
输出内容会因日志文件的格式以及mysqlbinlog工具使用的选项不同而略不同。二进制日志文件中具体内容的含义以及mysqlbinlog的可用选项可参考相关手册。这里就一些需要特别注意的情况进行说明。
二进制日志文件的格式包含行模式、语句模式和混合模式(也即有服务器决定在什么情况下记录什么类型的日志),基于语句的日志中事件信息包含执行的语句等,基于行的日志中事件信息包含的是行的变化信息等。混合模式的日志中两种类型的事件信息都会记录。为了便于查看记录了行变化信息的事件在当时具体执行了什么样的SQL语句可以使用mysqlbinlog工具的-v(--verbose)选项,该选项会将行事件重构成被注释掉的伪SQL语句,如果想看到更详细的信息可
以将该选项给两次如-vv,这样可以包含一些数据类型和元信息的注释内容,如
mysqlbinlog -v
mysqlbinlog -vv下面是例子
SET TIMESTAMP=1457620539/*!*/;
BEGIN
/*!*/;
# at 287621
# at 287706
#160310 22:35:39 server id 2573978858 end_log_pos 287706 Table_map: `_scd_0001`.`sc_schedule_log_0245` mapped to number 208596582
#160310 22:35:39 server id 2573978858 end_log_pos 288155 Write_rows: table id 208596582 flags: STMT_END_F
# at 288155
#160310 22:35:39 server id 2573978858 end_log_pos 288182 Xid = 29942407656
COMMIT/*!*/;
# at 288182
#160310 22:35:44 server id 2573978858 end_log_pos 288250 Query thread_id=14495814 exec_time=0 error_code=0
SET TIMESTAMP=1457620544/*!*/;
增加-v 参数选项后,打印出sql(伪sql)
SET TIMESTAMP=1457620539/*!*/;
BEGIN
/*!*/;
# at 287621
# at 287706
#160310 22:35:39 server id 2573978858 end_log_pos 287706 Table_map: `_scd_0001`.`sc_schedule_log_0245` mapped to number 208596582
#160310 22:35:39 server id 2573978858 end_log_pos 288155 Write_rows: table id 208596582 flags: STMT_END_F
### INSERT INTO _scd_0001.sc_schedule_log_0245
### SET
### @1=107560820
### @2=2016-03-10 22:35:39
### @3=2016-03-10 22:35:39
### @4=245
### @5=2
### @6='CYCLE'
### @7='ServiceIp:null;ClientIp:10.125.198.99;==>>java.lang.reflect.UndeclaredThrowableException <br/> null at: [$Proxy27.execute(Unknown Source)] <br/> Caused by: HSFServiceAddressNotFoundException-[HSF-Consumer] δĿַ at: [com.taobao.hsf.scm.plugin.SCMEnvironmentAddressSelect.constructException(SCMEnvironmentAddressSelect.java:90)]'
### @8=2
### @9=1
### @10=8076739
# at 288155
#160310 22:35:39 server id 2573978858 end_log_pos 288182 Xid = 29942407656
COMMIT/*!*/;
# at 288182
#160310 22:35:44 server id 2573978858 end_log_pos 288250 Query thread_id=14495814 exec_time=0 error_code=0
SET TIMESTAMP=1457620544/*!*/;
两个v 使用-vv参数后,效果是
SET TIMESTAMP=1457620539/*!*/;
BEGIN
/*!*/;
# at 287621
# at 287706
#160310 22:35:39 server id 2573978858 end_log_pos 287706 Table_map: `_scd_0001`.`sc_schedule_log_0245` mapped to number 208596582
#160310 22:35:39 server id 2573978858 end_log_pos 288155 Write_rows: table id 208596582 flags: STMT_END_F
### INSERT INTO _scd_0001.sc_schedule_log_0245
### SET
### @1=107560820 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2=2016-03-10 22:35:39 /* DATETIME meta=0 nullable=0 is_null=0 */
### @3=2016-03-10 22:35:39 /* DATETIME meta=0 nullable=0 is_null=0 */
### @4=245 /* LONGINT meta=0 nullable=0 is_null=0 */
### @5=2 /* LONGINT meta=0 nullable=0 is_null=0 */
### @6='CYCLE' /* VARSTRING(512) meta=512 nullable=1 is_null=0 */
### @7='ServiceIp:null;ClientIp:10.125.198.99;==>>java.lang.reflect.UndeclaredThrowableException <br/> null at: [$Proxy27.execute(Unknown Source)] <br/> Caused by: HSFServiceAddressNotFoundException-[HSF-Consumer] δĿַ at: [com.taobao.hsf.scm.plugin.SCMEnvironmentAddressSelect.constructException(SCMEnvironmentAddressSelect.java:90)]' /* VARSTRING(10000) meta=10000 nullable=1 is_null=0 */
### @8=2 /* INT meta=0 nullable=0 is_null=0 */
### @9=1 /* LONGINT meta=0 nullable=1 is_null=0 */
### @10=8076739 /* INT meta=0 nullable=0 is_null=0 */
# at 288155
#160310 22:35:39 server id 2573978858 end_log_pos 288182 Xid = 29942407656
COMMIT/*!*/;
# at 288182
#160310 22:35:44 server id 2573978858 end_log_pos 288250 Query thread_id=14495814 exec_time=0 error_code=0
SET TIMESTAMP=1457620544/*!*/;