首先确认开启日志功能(ON为启用):
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.00 sec)
查看使用中的日志文件(如果知道日志名,这步可以跳过):
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000027 | 11991 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
导出日志文件:
#退出 mysql,进入 mysql 的 bin 目录
mysql> exit;
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\upall>cd /d D:\wamp\bin\mysql\mysql5.6.12\bin
D:\wamp\bin\mysql\mysql5.6.12\bin>mysqlbinlog ../data/mysql-bin.000027 > %USERPROFILE%\桌面\mysql-bin.000027.log.txt
桌面上的 mysql-bin.000027.log.txt 文件就是导出的日志。
<完>