MYSQL binlog 日志内容查看
记录mysql数据库真正执行更改的所有操作(DML语句),不包含那些没有修改任何数据的语句,不会记录select和show这样的语句。
二进制日志的作用:
1、 可以完成主从复制的功能
2、 进行恢复操作。
数据可以通过binglog日志,使用mysqlbinlog命令,实现基于时间点和位置的恢复操作。
查看binglog参数信息:
mysql> show global variables like '%bin%';
+-----------------------------------------+-------------------------------------------------+
| Variable_name | Value |
+-----------------------------------------+-------------------------------------------------+
| bind_address | * |
| binlog_cache_size | 4194304 |
| binlog_checksum | CRC32 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_error_action | ABORT_SERVER |
| binlog_format | ROW |
| binlog_group_commit_sync_delay | 0 |
| binlog_group_commit_sync_no_delay_count | 0 |
| binlog_gtid_simple_recovery | ON |
| binlog_max_flush_queue_time | 0 |
| binlog_order_commits | ON |
| binlog_row_image | FULL |
| binlog_rows_query_log_events | OFF |
| binlog_stmt_cache_size | 32768 |
| innodb_api_enable_binlog | OFF |
| innodb_locks_unsafe_for_binlog | OFF |
| log_bin | ON |
| log_bin_basename | /mydata/mysql/mysql3307/logs/mysql-binlog |
| log_bin_index | /mydata/mysql/mysql3307/logs/mysql-binlog.index |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
| log_statements_unsafe_for_binlog | ON |
| max_binlog_cache_size | 1073741824 |
| max_binlog_size | 524288000 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| sync_binlog | 1 |
+-----------------------------------------+-------------------------------------------------+
26 rows in set (0.00 sec)
二进制文件用cat,head,或者tail命令是无法看的,需要通过mysqlbinglog 命令查看二进制日志,把日志转换格式后,输出到自定义的文件。
查看binglog日志文件:
mysqlbinlog --no-defaults -v -v --base64-output=decode-rows /mydata/mysql/mysql3307/logs/mysql-binlog.000021 /root/mysqlbinlog21.log
含义:
-v代表可以查看到的具体执行信息。
--base64-output 把二进制文件转换格式
以下是在ROW模式下,记录的记忆行的变更情况,变更前以及变更后的内容。
修改记录模式为:
set global binlog_format=statement;
set global binlog_format=mixed;
set global binlog_format=row;
查看生产文件内容/root/mysqlbinlog21.log
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#180521 1:09:56 server id 3307101 end_log_pos 123 CRC32 0x79f0cd1c Start: binlog v 4, server v 5.7.20-log created 180521 1:09:56 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 123
#180521 1:09:56 server id 3307101 end_log_pos 194 CRC32 0x96ca2d5f Previous-GTIDs
# d6a9d222-5282-11e8-bac7-080027691c44:1-15
# at 194
#180521 9:47:53 server id 3307101 end_log_pos 259 CRC32 0x737b7bad GTID last_committed=0 sequence_number=1 rbr_only=no
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:16'/*!*/;
# at 259
#180521 9:47:53 server id 3307101 end_log_pos 388 CRC32 0x9eba0300 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1526867273/*!*/;
SET @@session.pseudo_thread_id=3/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1436549152/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
SET @@session.explicit_defaults_for_timestamp=1/*!*/;
create table test.zs(a timestamp,b timestamp,c timestamp)
/*!*/;
# at 388
#180521 9:49:28 server id 3307101 end_log_pos 453 CRC32 0x8a902dce GTID last_committed=1 sequence_number=2 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:17'/*!*/;
# at 453
#180521 9:49:28 server id 3307101 end_log_pos 521 CRC32 0xfe907eed Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1526867368/*!*/;
BEGIN
/*!*/;
# at 521
#180521 9:49:28 server id 3307101 end_log_pos 571 CRC32 0x528b2287 Table_map: `test`.`zs` mapped to number 219
# at 571
#180521 9:49:28 server id 3307101 end_log_pos 607 CRC32 0x2bb11644 Write_rows: table id 219 flags: STMT_END_F
### INSERT INTO `test`.`zs`
### SET
### @1=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 607
#180521 9:49:28 server id 3307101 end_log_pos 638 CRC32 0xf1b37ef5 Xid = 26
COMMIT/*!*/;
# at 638
#180521 9:49:30 server id 3307101 end_log_pos 703 CRC32 0x8d1451b6 GTID last_committed=2 sequence_number=3 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:18'/*!*/;
# at 703
#180521 9:49:30 server id 3307101 end_log_pos 771 CRC32 0x17f458cd Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1526867370/*!*/;
BEGIN
/*!*/;
# at 771
#180521 9:49:30 server id 3307101 end_log_pos 821 CRC32 0x8608f3f8 Table_map: `test`.`zs` mapped to number 219
# at 821
#180521 9:49:30 server id 3307101 end_log_pos 857 CRC32 0x61faa6a3 Write_rows: table id 219 flags: STMT_END_F
### INSERT INTO `test`.`zs`
### SET
### @1=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 857
#180521 9:49:30 server id 3307101 end_log_pos 888 CRC32 0xc555dada Xid = 27
COMMIT/*!*/;
# at 888
#180521 9:49:31 server id 3307101 end_log_pos 953 CRC32 0x152275a2 GTID last_committed=3 sequence_number=4 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:19'/*!*/;
# at 953
#180521 9:49:31 server id 3307101 end_log_pos 1021 CRC32 0x68fadf15 Query thread_id=3 exec_time=0 error_code=0
SET TIMESTAMP=1526867371/*!*/;
BEGIN
/*!*/;
# at 1021
#180521 9:49:31 server id 3307101 end_log_pos 1071 CRC32 0x999fd973 Table_map: `test`.`zs` mapped to number 219
# at 1071
#180521 9:49:31 server id 3307101 end_log_pos 1107 CRC32 0x0c1bb219 Write_rows: table id 219 flags: STMT_END_F
### INSERT INTO `test`.`zs`
### SET
### @1=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 1107
#180521 9:49:31 server id 3307101 end_log_pos 1138 CRC32 0x0e581441 Xid = 28
COMMIT/*!*/;
# at 1138
#180521 9:51:29 server id 3307101 end_log_pos 1203 CRC32 0x6c5d54df GTID last_committed=4 sequence_number=5 rbr_only=no
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:20'/*!*/;
# at 1203
#180521 9:51:29 server id 3307101 end_log_pos 1290 CRC32 0x93e104d9 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1526867489/*!*/;
SET @@session.time_zone='SYSTEM'/*!*/;
flush privileges
/*!*/;
# at 1290
#180521 10:02:20 server id 3307101 end_log_pos 1355 CRC32 0x07b66739 GTID last_committed=5 sequence_number=6 rbr_only=no
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:21'/*!*/;
# at 1355
#180521 10:02:20 server id 3307101 end_log_pos 1520 CRC32 0x48415c32 Query thread_id=7 exec_time=0 error_code=0
use `test`/*!*/;
SET TIMESTAMP=1526868140/*!*/;
SET @@session.explicit_defaults_for_timestamp=0/*!*/;
create table zs1(a timestamp,b timestamp null default null,c timestamp null default null)
/*!*/;
# at 1520
#180521 10:05:36 server id 3307101 end_log_pos 1585 CRC32 0x749f7319 GTID last_committed=6 sequence_number=7 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:22'/*!*/;
# at 1585
#180521 10:05:36 server id 3307101 end_log_pos 1657 CRC32 0x381adad5 Query thread_id=7 exec_time=0 error_code=0
SET TIMESTAMP=1526868336/*!*/;
BEGIN
/*!*/;
# at 1657
#180521 10:05:36 server id 3307101 end_log_pos 1708 CRC32 0x8b75b8d0 Table_map: `test`.`zs1` mapped to number 220
# at 1708
#180521 10:05:36 server id 3307101 end_log_pos 1748 CRC32 0x6f7e879b Write_rows: table id 220 flags: STMT_END_F
### INSERT INTO `test`.`zs1`
### SET
### @1=1526868336 /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 1748
#180521 10:05:36 server id 3307101 end_log_pos 1779 CRC32 0x8f7b45df Xid = 74
COMMIT/*!*/;
# at 1779
#180521 10:06:01 server id 3307101 end_log_pos 1844 CRC32 0x0857208f GTID last_committed=7 sequence_number=8 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:23'/*!*/;
# at 1844
#180521 10:06:01 server id 3307101 end_log_pos 1916 CRC32 0xf8b57357 Query thread_id=7 exec_time=0 error_code=0
SET TIMESTAMP=1526868361/*!*/;
BEGIN
/*!*/;
# at 1916
#180521 10:06:01 server id 3307101 end_log_pos 1967 CRC32 0x71f69634 Table_map: `test`.`zs1` mapped to number 220
# at 1967
#180521 10:06:01 server id 3307101 end_log_pos 2007 CRC32 0x8398dbd6 Write_rows: table id 220 flags: STMT_END_F
### INSERT INTO `test`.`zs1`
### SET
### @1=1526868361 /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 2007
#180521 10:06:01 server id 3307101 end_log_pos 2038 CRC32 0xae8d3064 Xid = 77
COMMIT/*!*/;
# at 2038
#180521 10:06:02 server id 3307101 end_log_pos 2103 CRC32 0x50fdabc1 GTID last_committed=8 sequence_number=9 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:24'/*!*/;
# at 2103
#180521 10:06:02 server id 3307101 end_log_pos 2175 CRC32 0x38a21fb3 Query thread_id=7 exec_time=0 error_code=0
SET TIMESTAMP=1526868362/*!*/;
BEGIN
/*!*/;
# at 2175
#180521 10:06:02 server id 3307101 end_log_pos 2226 CRC32 0x4a1b7b27 Table_map: `test`.`zs1` mapped to number 220
# at 2226
#180521 10:06:02 server id 3307101 end_log_pos 2266 CRC32 0x397de1b3 Write_rows: table id 220 flags: STMT_END_F
### INSERT INTO `test`.`zs1`
### SET
### @1=1526868362 /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 2266
#180521 10:06:02 server id 3307101 end_log_pos 2297 CRC32 0xe2727b87 Xid = 78
COMMIT/*!*/;
# at 2297
#180521 10:06:03 server id 3307101 end_log_pos 2362 CRC32 0x3cadd4ea GTID last_committed=9 sequence_number=10 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:25'/*!*/;
# at 2362
#180521 10:06:03 server id 3307101 end_log_pos 2434 CRC32 0x06a0be65 Query thread_id=7 exec_time=0 error_code=0
SET TIMESTAMP=1526868363/*!*/;
BEGIN
/*!*/;
# at 2434
#180521 10:06:03 server id 3307101 end_log_pos 2485 CRC32 0xea1f5733 Table_map: `test`.`zs1` mapped to number 220
# at 2485
#180521 10:06:03 server id 3307101 end_log_pos 2525 CRC32 0xba9bf9de Write_rows: table id 220 flags: STMT_END_F
### INSERT INTO `test`.`zs1`
### SET
### @1=1526868363 /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */
### @2=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
### @3=NULL /* TIMESTAMP(0) meta=0 nullable=1 is_null=1 */
# at 2525
#180521 10:06:03 server id 3307101 end_log_pos 2556 CRC32 0x1961d7b0 Xid = 79
COMMIT/*!*/;
# at 2556
#180521 10:09:00 server id 3307101 end_log_pos 2621 CRC32 0xe802a496 GTID last_committed=10 sequence_number=11 rbr_only=no
SET @@SESSION.GTID_NEXT= 'd6a9d222-5282-11e8-bac7-080027691c44:26'/*!*/;
# at 2621
#180521 10:09:00 server id 3307101 end_log_pos 2712 CRC32 0x1b99ba5c Query thread_id=7 exec_time=0 error_code=0
SET TIMESTAMP=1526868540/*!*/;
flush privileges
/*!*/;
mysqlbinlog: File '/root/mysqlbinlog21.log' not found (Errcode: 2 - No such file or directory)
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
MYSQL binlog 日志内容查看的更多相关文章
- Mysql Binlog日志详解
一.Mysql Binlog格式介绍 Mysql binlog日志有三种格式,分别为Statement,MiXED,以及ROW! 1.Statement:每一条会修改数据的sql都会记录在 ...
- MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库【转载】
转自 MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库 - _安静 - 博客园http://www.cnblogs.com/xionghui/archive/2012/ ...
- 删除MySQL binlog日志的方法
对于比较繁忙的OLTP(在线事务处理)系统,由于每天生成日志量大,这些日志如果长时间不清除,将会对磁盘空间带来很大的浪费.因此,定期删除日志是DBA维护MySQL数据库的一个重要工作内容.下面跟大家分 ...
- MySQL binlog日志操作详解
MySQL的二进制日志可以说是MySQL最重要的日志了,它记录了所有的DDL和DML(除了数据查询语句)语句,以事件形式记录,还包含语句所执行的消耗的时间,MySQL的二进制日志是事务安全型的. bi ...
- MySQL binlog日志三种模式选择及配置
在认识binlog日志三种模式前,先了解一下解析binlog日志的命令工mysqlbinlog.mysqlbinlog工具的作用是解析mysql的二进制binlog日志内容,把二进制日志解析成可以在M ...
- MySQL - binlog日志简介及设置
基本概念 binlog是Mysql sever层维护的一种二进制日志,与innodb引擎中的redo/undo log是完全不同的日志:其主要是用来记录对mysql数据更新或潜在发生更新的SQL语句, ...
- 看数据库的文件大小 MySQL Binlog日志的生成和清理规则
小结: 1.避免并行大大事务对磁盘.内存的消耗: MySQL数据文件导致实例空间满的解决办法_空间/内存_常见问题_云数据库 RDS 版-阿里云 https://help.aliyun.com/kno ...
- 【转载】mysql binlog日志自动清理及手动删除
说明:当开启mysql数据库主从时,会产生大量如mysql-bin.00000* log的文件,这会大量耗费您的硬盘空间.mysql-bin.000001mysql-bin.000002mysql-b ...
- mysql binlog日志自动清理及手动删除
说明:当开启mysql数据库主从时,会产生大量如mysql-bin.00000* log的文件,这会大量耗费您的硬盘空间.mysql-bin.000001mysql-bin.000002mysql-b ...
随机推荐
- Oracle动态性能表-V$SESSION_WAIT,V$SESSION_EVENT
(1)-V$SESSION_WAIT 这是一个寻找性能瓶颈的关键视图.它提供了任何情况下session在数据库中当前正在等待什么(如果session当前什么也没在做,则显示它最后的等待事件).当系统存 ...
- ACM/OI 出题用
之前出题,很苦恼出数据和检查程序,因为很多繁琐的工作,还很可能小手一抖出问题. 最近又在出题...想起之前的对拍脚本,感觉不能更方便,于是撸了一套出题用的小工具,也学习了一点点的DOS命令 首先是输入 ...
- Tool-DB:Navicat
ylbtech-Tool-DB:Navicat Navicat是一套快速.可靠并价格相当便宜的数据库管理工具,专为简化数据库的管理及降低系统管理成本而设.它的设计符合数据库管理员.开发人员及中小企业的 ...
- [十二省联考2019] 异或粽子 解题报告 (可持久化Trie+堆)
interlinkage: https://www.luogu.org/problemnew/show/P5283 description: solution: 显然有$O(n^2)$的做法,前缀和优 ...
- [jzoj 5662] 尺树寸泓 解题报告 (线段树+中序遍历)
interlinkage: https://jzoj.net/senior/#contest/show/2703/1 description: solution: 发现$dfs$序不好维护 注意到这是 ...
- CZLayer的阴影
CALayer有一个shadow属性 意思是阴影 shadowcolor //颜色 shadowoffset //偏移 shadowOpacity //透明度 layer有一个方法 mas ...
- POJ 1384 Piggy-Bank DP
一个完全背包 很裸,对于我这种DP渣渣都能1A.. // by SiriusRen #include <cstdio> #include <cstring> #include ...
- ASP.net 中 OutputCache 指令各个参数的作用
使用@ OutputCache指令 使用@ OutputCache指令,能够实现对页面输出缓存的一般性需要.@ OutputCache指令在ASP.NET页或者页中包含的用户控件的头部声明.这种方式非 ...
- Oracle学习系类篇(一)
1.表空间介绍 oarcle数据库真正存放数据的是数据文件(data files),Oarcle表空间(tablespaces)实际上是一个逻辑的概念,他在物理上是并不存在的,那么把一组data fi ...
- sql server 授权相关命令
原文:https://blog.csdn.net/hfdgjhv/article/details/83834076 https://www.cnblogs.com/shi-yongcui/p/7755 ...