1.登录mysql数据库查看
show variables like '%bin%':查看my.in/my.conf文件中是否开启的bin_log 日志
show binlog events :默认查看binlog日志第一个文件;
show binlog events in 'mysql-bin.000035':查看具体的文件
show master status\G:查看正在写入的日志/最后使用的binlog日志
show binary logs:查看binlog日志列表
flush logs:使用新的binlog日志
show master status:最新的日志文件
reset master 清除所有的binlog 日志
mysql> show variables like '%bin%'
-> ;
+-----------------------------------------+----------------------+
| Variable_name | Value |
+-----------------------------------------+----------------------+
| binlog_cache_size | 32768 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_format | MIXED |
| binlog_stmt_cache_size | 32768 |
| innodb_locks_unsafe_for_binlog | OFF |
| log_bin | ON |
| log_bin_trust_function_creators | OFF |
| max_binlog_cache_size | 18446744073709547520 |
| max_binlog_size | 1073741824 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| sql_log_bin | ON |
| sync_binlog | 0 |
+-----------------------------------------+----------------------+
12 rows in set (0.00 sec)
mysql> show master status;
+------------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000009 | 182768419 | | |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> flush logs;
Query OK, 0 rows affected (0.18 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000010 | 107 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql>
2.本地查看
mysqlbinlog --start-datetime='2015-02-07 10:00:00' --stop-datetime='2015-02-07 12:00:00' -d 数据库名字 binlog文件路径;
3.远程查看
mysqlbinlog -u username -p password -**** -P3306 \
--read-from-remote-server --start-datetime='2013-09-10 23:00:00' --stop-datetime='2013-09-10 23:30:00' mysql-bin.000001 > t.binlog