一、MySQL Binlog日志文件相關操作
1.1、登錄到mysql查看binlog
只查看第一個binlog文件的內容
show binlog events;
查看指定binlog文件的內容
show binlog events in 'mysql-bin.000002';
查看當前正在寫入的binlog文件
show master status\G
獲取binlog文件列表
show binary logs;
用mysqlbinlog工具查看
注意:
不要查看當前正在寫入的binlog文件
不要加--force參數強制訪問
如果binlog格式是行模式的,請加 -vv參數
本地查看
基于開始/結束時間
mysqlbinlog?--start-datetime='2013-09-10?00:00:00' --stop-datetime='2013-09-10?01:01:01' -d 庫名?二進制文件
基于pos值
mysqlbinlog --start-postion=107?--stop-position=1000?-d?庫名?二進制文件
遠程查看
指定開始/結束時間,并把結果重定向到本地t.binlog文件中.
mysqlbinlog?-u?username?-p?password?-hl-db1.dba.beta.cn6.qunar.com?-P3306?\--read-from-remote-server?--start-datetime='2013-09-10?23:00:00'--stop-datetime='2013-09-10?23:30:00'mysql