mysqlbinlog使用记录

首先要确认mysql启用了binlog功能。一般默认启用。

mysql> select @@log_bin;
+-----------+
| @@log_bin |
+-----------+
|         1 |
+-----------+

然后确认binlog目录

mysql> select @@log_bin_basename;
+----------------------------+
| @@log_bin_basename         |
+----------------------------+
| /data/mysql/data/mysql-bin |
+----------------------------+
1 row in set (0.20 sec)

再确认binlog格式,一般都是ROW

mysql> select @@binlog_format;
+-----------------+
| @@binlog_format |
+-----------------+
| ROW             |
+-----------------+
1 row in set (0.24 sec)

查看下当前的binlog文件。最后一个。

mysql> show master status;
+------------------+-----------+--------------+------------------+------------------------------------------------+
| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                              |
+------------------+-----------+--------------+------------------+------------------------------------------------+
| mysql-bin.000162 | 508947599 |              |                  | 8c6a1022-2488-11ee-823a-fa163e4f0fbf:1-1706820 |
+------------------+-----------+--------------+------------------+------------------------------------------------+
1 row in set (0.19 sec)

查看binlog清单。


mysql> show master logs;
+------------------+------------+-----------+
| Log_name         | File_size  | Encrypted |
+------------------+------------+-----------+
| mysql-bin.000097 | 1267374431 | No        |
| mysql-bin.000098 | 1078842954 | No        |
| mysql-bin.000099 | 1076402277 | No        |
| mysql-bin.000100 | 1074662461 | No        |
| mysql-bin.000101 | 1129645727 | No        |
| mysql-bin.000102 | 1073854117 | No        |
| mysql-bin.000103 | 1076120021 | No        |
| mysql-bin.000104 | 1163004975 | No        |
| mysql-bin.000105 | 1080999999 | No        |
| mysql-bin.000106 | 1123681007 | No        |
| mysql-bin.000107 | 1096492121 | No        |
| mysql-bin.000108 | 1080796650 | No        |
| mysql-bin.000109 | 1074606514 | No        |
| mysql-bin.000110 | 1094934164 | No        |
| mysql-bin.000111 | 1075325447 | No        |
| mysql-bin.000112 | 1204392658 | No        |
| mysql-bin.000113 | 1180372937 | No        |
| mysql-bin.000114 | 1196526678 | No        |
| mysql-bin.000115 | 1238177050 | No        |
| mysql-bin.000116 | 1074988755 | No        |
| mysql-bin.000117 | 1091344404 | No        |
| mysql-bin.000118 | 1076183240 | No        |
| mysql-bin.000119 | 1081950716 | No        |
| mysql-bin.000120 | 1109171293 | No        |
| mysql-bin.000121 | 1101011874 | No        |
| mysql-bin.000122 | 1218723442 | No        |
| mysql-bin.000123 | 1183060961 | No        |
| mysql-bin.000124 | 1106412574 | No        |
| mysql-bin.000125 | 1250171532 | No        |
| mysql-bin.000126 | 1078337881 | No        |
| mysql-bin.000127 | 1076340326 | No        |
| mysql-bin.000128 | 1073886411 | No        |
| mysql-bin.000129 | 1073771450 | No        |
| mysql-bin.000130 | 1073763024 | No        |
| mysql-bin.000131 | 1073754658 | No        |
| mysql-bin.000132 | 1073765124 | No        |
| mysql-bin.000133 | 1073758960 | No        |
| mysql-bin.000134 | 1167060782 | No        |
| mysql-bin.000135 | 1190829992 | No        |
| mysql-bin.000136 | 1096377082 | No        |
| mysql-bin.000137 | 1074835535 | No        |
| mysql-bin.000138 | 1097946487 | No        |
| mysql-bin.000139 | 1079454725 | No        |
| mysql-bin.000140 | 1073757655 | No        |
| mysql-bin.000141 | 1187881785 | No        |
| mysql-bin.000142 | 1096423858 | No        |
| mysql-bin.000143 | 1233191324 | No        |
| mysql-bin.000144 | 1080399415 | No        |
| mysql-bin.000145 | 1207148115 | No        |
| mysql-bin.000146 | 1211077714 | No        |
| mysql-bin.000147 | 1155530016 | No        |
| mysql-bin.000148 | 1141697366 | No        |
| mysql-bin.000149 | 1104053983 | No        |
| mysql-bin.000150 | 1181112005 | No        |
| mysql-bin.000151 | 1136589759 | No        |
| mysql-bin.000152 | 1077718940 | No        |
| mysql-bin.000153 | 1148381060 | No        |
| mysql-bin.000154 | 1185805639 | No        |
| mysql-bin.000155 | 1073741887 | No        |
| mysql-bin.000156 | 1104320103 | No        |
| mysql-bin.000157 | 1088572221 | No        |
| mysql-bin.000158 | 1076297985 | No        |
| mysql-bin.000159 | 1232823373 | No        |
| mysql-bin.000160 | 1213815833 | No        |
| mysql-bin.000161 | 1122061331 | No        |
| mysql-bin.000162 |  510032311 | No        |
+------------------+------------+-----------+

确认下binlog的文件

[iwhalecloud@apaas-mid1 data]$ lsapaas-mid1.log                  app_5195062153216_default_dev   app_d_1004304311066894336_dev   app_d_1010718326218174464_dev   app_d_1011464263104589824_dev   app_d_1016624577895215104_dev   app_d_1027753803562999808_dev   ca.pem               mysql-bin.000107   mysql-bin.000133   mysql-bin.000159app_0171769606782976_test_dev   app_587242401792_default_test   app_d_1004305219343425536_dev   app_d_1010790433914744832_dev   app_d_1011468334553231360_dev   app_d_1016630849134669824_dev   app_d_1027834867983568896_dev   client-cert.pem      mysql-bin.000108   mysql-bin.000134   mysql-bin.000160app_039531520_testappdemo_dev   app_618118144_zerocode_db_dev   app_d_1004305335215267840_dev   app_d_1010810408964583424_dev   app_d_1011475911693430784_dev   app_d_1016874600214048768_dev   app_d_1031846359492018176_dev   client-key.pem       mysql-bin.000109   mysql-bin.000135   mysql-bin.000161app_1154719241531392_utf8_dev   app_624027447296_default_test   app_d_1004305483873984512_dev   app_d_1010817221210533888_dev   app_d_1011512375550537728_dev   app_d_1017310111265206272_dev   app_d_1032242791453638656_dev   fastflow             mysql-bin.000110   mysql-bin.000136   mysql-bin.000162app_1189251336433664_jdxt_dev   app_6488617971712_shucun_test   app_d_1004326979078004736_dev   app_d_1010825204518744064_dev   app_d_1011538998677073920_dev   app_d_1018337333302321152_dev   app_d_1033622580274925568_dev  '#ib_16384_0.dblwr'   mysql-bin.000111   mysql-bin.000137   mysql.ibdapp_127492251648_default_test   app_659885162496_default_test   app_d_1005737741596581888_dev   app_d_1010832101951008768_dev   app_d_1011575392178925568_dev   app_d_1018338118778019840_dev   app_d_1033625372782837760_dev  '#ib_16384_1.dblwr'   mysql-bin.000112   mysql-bin.000138   mysql_upgrade_infoapp_138032611328_default_test   app_666318913536_default_test   app_d_1005738777421897728_dev   app_d_1010907921470058496_dev   app_d_1011575553651240960_dev   app_d_1018340928600989696_dev   app_d_1033983426992881664_dev   ib_buffer_pool       mysql-bin.000113   mysql-bin.000139   performance_schemaapp_174031101952_default_test   app_6845819412480_default_dev   app_d_1005739158608633856_dev   app_d_1010908254564904960_dev   app_d_1011827666318913536_dev   app_d_1018412911153754112_dev   app_d_1034827970723319808_dev   ibdata1              mysql-bin.000114   mysql-bin.000140   private_key.pemapp_1945102188544_default_dev   app_709634650112_default_test   app_d_1005739257745203200_dev   app_d_1010908346898313216_dev   app_d_1012278439994707968_dev   app_d_1018687570684260352_dev   app_d_1034828040540999680_dev   ibtmp1               mysql-bin.000115   mysql-bin.000141   public_key.pemapp_1945102188569_laodian_dev   app_725581508608_test_tt1_dev   app_d_1005739323465752576_dev   app_d_1010924624027447296_dev   app_d_1012278563198193664_dev   app_d_1019055184992382976_dev   app_d_1036464803857166336_dev  '#innodb_redo'        mysql-bin.000116   mysql-bin.000142   server-cert.pemapp_195062153216_default_test   app_791453638656_default_test   app_d_1006012396081340416_dev   app_d_1011079920993562624_dev   app_d_1013338123723853824_dev   app_d_1019873200897794048_dev   app_d_1036519544385974272_dev  '#innodb_temp'        mysql-bin.000117   mysql-bin.000143   server-key.pemapp_196571193344_default_test   app_816690434048_default_test   app_d_1006122233230352384_dev   app_d_1011104587242401792_dev   app_d_1013338201851154432_dev   app_d_1023842551653220352_dev   app_d_1036519946628116480_dev   lcdp                 mysql-bin.000118   mysql-bin.000144   sysapp_2138032611328_default_dev   app_8227738279612416_test_dev   app_d_1006132308405739520_dev   app_d_1011106345658216448_dev   app_d_1013338422039531520_dev   app_d_1024219997648994304_dev   app_d_1037656375662415872_dev   lcdp_erm             mysql-bin.000119   mysql-bin.000145   undo_001app_218821236633600_db_sq_dev   app_825204518744064_test1_dev   app_d_1006446232452059136_dev   app_d_1011149288259579904_dev   app_d_1013358153484193792_dev   app_d_1024231818401431552_dev   app_d_1040171117312413696_dev   lcdp_run             mysql-bin.000120   mysql-bin.000146   undo_002app_227738279612416_test_test   app_847371726848_default_test   app_d_1006448431248822272_dev   app_d_1011164197059948544_dev   app_d_1014489244858773504_dev   app_d_1024232357008785408_dev   app_od_974142457073610752_dev   master-bin.index     mysql-bin.000121   mysql-bin.000147   zzh_map_demoapp_233230352384_default_test   app_86488617971712_shucun_dev   app_d_1006457700924903424_dev   app_d_1011166023419293696_dev   app_d_1014528247108661248_dev   app_d_1024565990860390400_dev   app_od_975232884835905536_dev   mysql                mysql-bin.000122   mysql-bin.000148   zzh_map_demo2app_233238469062656_test_test   app_9233238469062656_test_dev   app_d_1006458292971884544_dev   app_d_1011167920884674560_dev   app_d_1014805207286214656_dev   app_d_1024566471858978816_dev   app_od_978592102489714688_dev   mysql-bin.000097     mysql-bin.000123   mysql-bin.000149app_308405739520_default_test   app_945102188544_default_test   app_d_1006459888120221696_dev   app_d_1011177196571193344_dev   app_d_1014827357393055744_dev   app_d_1024572042514006016_dev   app_od_978825127492251648_dev   mysql-bin.000098     mysql-bin.000124   mysql-bin.000150app_3238079225856_default_dev   app_979078004736_default_test   app_d_1006460401544974336_dev   app_d_1011189251336433664_dev   app_d_1014834673609797632_dev   app_d_1024572572867506176_dev   app_od_999137055907729408_dev   mysql-bin.000099     mysql-bin.000125   mysql-bin.000151app_335215267840_default_test   app_98871352568696832_ddd_dev   app_d_1006460812259610624_dev   app_d_1011191239532998656_dev   app_d_1014837617249759232_dev   app_d_1024573190734086144_dev   app_od_999244520643506176_dev   mysql-bin.000100     mysql-bin.000126   mysql-bin.000152app_396081340416_default_test   app_9962294104064_default_dev   app_d_1006751033644433408_dev   app_d_1011204323920179200_dev   app_d_1016166193735675904_dev   app_d_1024579370265620480_dev   app_od_999244709634650112_dev   mysql-bin.000101     mysql-bin.000127   mysql-bin.000153app_408964583424_default_test   app_d_1004300925747666944_dev   app_d_1006755011660759040_dev   app_d_1011205372915609600_dev   app_d_1016186488617971712_dev   app_d_1024579487827230720_dev   app_sc_prod                     mysql-bin.000102     mysql-bin.000128   mysql-bin.000154app_4623921942528_default_dev   app_d_1004301437498892288_dev   app_d_1007182270792089600_dev   app_d_1011220072671866880_dev   app_d_1016198049780740096_dev   app_d_1024580960116015104_dev   app_st_993335847371726848_dev   mysql-bin.000103     mysql-bin.000129   mysql-bin.000155app_4689726349312_default_dev   app_d_1004302221812768768_dev   app_d_1009283816690434048_dev   app_d_1011435482344189952_dev   app_d_1016218821236633600_dev   app_d_1024582367277088768_dev   app_szxc                        mysql-bin.000104     mysql-bin.000130   mysql-bin.000156app_488617971712_default_test   app_d_1004302307896664064_dev   app_d_1010401188190236672_dev   app_d_1011438016030961664_dev   app_d_1016591945580949504_dev   app_d_1024592473556127744_dev   auto.cnf                        mysql-bin.000105     mysql-bin.000131   mysql-bin.000157app_512927195136_default_test   app_d_1004304082401828864_dev   app_d_1010436753635815424_dev   app_d_1011459951754342400_dev   app_d_1016615229982781440_dev   app_d_1027746486259798016_dev   ca-key.pem                      mysql-bin.000106     mysql-bin.000132   mysql-bin.000158

binlog是二进制文件,直接用文本解析会存在一些乱码。使用mysqlbinlog工具处理后在可以正常读取。mysqlbinlog工具一般安装mysql的时候会默认安装。

mysqlbinlog --base64-output=DECODE-ROWS --start-datetime='2023-11-20 09:00:00' --stop-datetime='2023-11-20 11:00:00' /data/mysql/data/mysql-bin.000161 > mysqllog5.log

其中由于格式是ROW格式,如果直接导出,执行的sql语句会变成类似base64加密后格式样式。

所以追加了 --base64-output=DECODE-ROWS,就是为了转换成明文sql。

其他的start-datetime什么的都好理解,就不在说明了。

如果输出文件显示,应该是没有符合条件的数据。例如下面这个就是由于对应binlog的文件中不包含指定时间段的数据导致的。这时可以切换binlog目录测试。简单点看一下输出文件大小就可以知道是否包含有效数据了。

# The proper term is pseudo_replica_mode, but we use this compatibility alias
# to make the statement usable on server versions 8.0.24 and older.
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
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*/;

上图就是没有数据的文件大小,不足1k。

log4和log5条件一致,不过log5把ROW解码了,所以文件小了非常多。--base64-output=DECODE-ROWS就是这个的作用。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/150096.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

安装Nginx时报:./configure: error: can not define uint32_t

安装版本:v.1.25.3 安装命令: ./configure --prefix/opt/nginx/1.25.3 && make && make install 执行命令后出现异常,如图: 解决方法: yum install -y kernel-headers kernel-devel gcc make

大模型真的会让软件测试人员下岗吗?

在今年3月写过一篇文章:又一次被震惊:从生成和细化需求到应用各种方法设计测试用例 ,展示了chatGPT生成测试用例,而且可以用不同的方法生成测试用例,在我们的引导下它还能补充测试用例、完善测试用例。半年之后&#x…

北邮22级信通院数电:Verilog-FPGA(10)第十周实验 实现移位寄存器74LS595

北邮22信通一枚~ 跟随课程进度更新北邮信通院数字系统设计的笔记、代码和文章 持续关注作者 迎接数电实验学习~ 获取更多文章,请访问专栏: 北邮22级信通院数电实验_青山如墨雨如画的博客-CSDN博客 目录 一.代码部分 二.管脚分配 三.实现过程讲解及效…

关于爬虫中的hook(defineProperty,hook cookies, hook载荷数据,hookXHR)

关于爬虫中的hook: defineProperty var people {age: 19, }; var count20; console.log(people.age) // 参数:对象 属性名字 函数 Object.defineProperty(people, age, {get: function () {console.log(获取值!);return count;},// set: …

SOME/IP 协议介绍(五)指南

指南(信息性) 选择传输协议 SOME/IP直接支持互联网上使用最广泛的两种传输协议:用户数据报协议(UDP)和传输控制协议(TCP)。UDP是一种非常简洁的传输协议,仅支持最重要的功能&#…

在电脑PC端可以分类记笔记的软件选择哪个?

选择用电脑来记录笔记是比较便捷的,电脑屏幕比较大,操作起来比较便捷。但是很多人用电脑来记录笔记,通常会使用电脑上自带的记事本、文档记事工具来整合笔记,打开文档记事本类的软件,密密麻麻的文字呈现出来。 选择用…

Cesium点位弹窗

1.弹窗没法向加入点位一样加入到地图内部,entity没法实现 2.使用绝对定位,将地图组件通过定位加入到地图上,注意弹窗层级一定在地图上 3.通过判断点击位置是否是点位来获取entity信息,将信息显示在弹窗 4.将点击处点位的经纬度转为…

RHCSA --- Linux存储管理

存储管理 Boot:可引导操作系统的分区(必须是主分区) 分区 ll /dev/nvme0n* 表示的是 nvme接口的磁盘 0n1 1 0n2 2 0n3 3 brw-rw----. 1 root disk 259, 0 Nov 15 19:31 /dev/nvme0n1 磁盘1 brw-rw----. 1 ro…

算法之冒泡排序

算法之冒泡排序 冒泡排序Bubble Sort 交换排序相邻元素两两比较大小,有必要则交换。元素越小或越大,就会在数列中慢慢的交换并“浮”向顶端,如同水泡咕嘟咕嘟往上冒。 核心算法 排序算法,一般都实现为就地排序,输出…

vscode c++ 报错identifier “string“ is undefined

vscode c 报identifier “string” is undefined 问题 新装了电脑, 装好vsc和g等, 发现报错 但开头并没问题 解决 shiftctrlp选择 C/C Edit:COnfigurations (JSON)自动生成打开 c_cpp_properties.json添加g路径等 "cStandard": "c11","cppStanda…

【数据结构(二)】单链表(3)

文章目录 1. 链表介绍2. 单链表应用实例2.1. 顺序添加方式2.1.1. 思路分析2.1.2. 代码实现 2.2. 按照编号顺序添加方式2.2.1. 思路分析2.2.2. 代码实现 3. 单链表节点的修改3.1. 思路分析3.2. 代码实现 4. 单链表节点的删除4.1. 思路分析4.2. 代码实现 5. 单链表常见面试题5.1.…

Universal adversarial perturbations(2017 CVPR)

Universal adversarial perturbations----《普遍对抗扰动》 通俗UAP算法步骤理解:对于 x i ∈ X {x_i} \in X xi​∈X 的每个采样数据点,比较 k ^ ( x i v ) \hat k({x_i} v) k^(xi​v) 与 k ^ ( x i ) \hat k({x_i}) k^(xi​) ,如果 k…

Rust与其他语言对比:优势在哪里?

大家好!我是lincyang。 今天,我们将深入探讨Rust语言与其他编程语言比较的优势,并通过具体的代码示例和性能数据来加深理解。 Rust与其他语言的比较 1. 内存安全性 Rust:采用所有权系统,编译器在编译时检查内存安全…

西南科技大学814考研二

C语言数据结构与算法 线性表 顺序表(静态分配内存) #include <stdio.h> #include <stdbool.h> //静态顺序表 #define MAX_SIZE 8 //顺序表储存的数据类型 typedef int ElemType; typedef struct {ElemType data[MAX_SIZE];int length; }SeqList; //初始化顺序表…

redis 非关系型数据库

redis 非关系型数据库&#xff0c;缓存型数据库。 关系型数据库和非关系型数据库的区别 关系型数据库是一个机构化的数据库&#xff0c;行和列。 列&#xff1a;声明对象 行&#xff1a;记录对象属性。 表与表之间是有关联&#xff0c;使用sql语句&#xff0c;来对指定的表…

Oracle 存储过程数据插入临时表慢以及SQL语句查询慢

/*parallel*/ 解释: 一般表数据量比较大&#xff08;超过100万&#xff09;时&#xff0c;可以使用parallel强制启动并行度来提升查询速度 用法&#xff1a;/*parallel(table_short_name,cash_number)*/ 可以加到insert、delete、update、select的后面来使用 比如&#xff…

Linux:安装MySQL服务(非docker方式)

1、下载安装包 下载MySQL安装包&#xff0c;需要Oracle官网的账号 下面是网友提供的账号及密码&#xff0c;亲测有效。 账户&#xff1a;3028064308qq.com 我用的这个&#xff0c;可以登陆 密码&#xff1a;OraclePassword123!Oracle Account: 602205528qq.com Oracle Pass…

计算机毕业设计选题推荐-掌心办公微信小程序/安卓APP-项目实战

✨作者主页&#xff1a;IT毕设梦工厂✨ 个人简介&#xff1a;曾从事计算机专业培训教学&#xff0c;擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。 ☑文末获取源码☑ 精彩专栏推荐⬇⬇⬇ Java项目 Py…

分形简单版

我的代码&#xff1a; #include<bits/stdc.h> using namespace std; const int N1000; int n; char s[N][N]; void work(int x) {if(x1) {s[0][0]*;return;}work(x-1);for(int i0;i<(1<<x-2);i)for(int j(1<<x-2);j<(1<<x-1);j) s[i][j]s[i][j-(…

Java的IO流-打印流

打印流 PrintStream public void println&#xff08;&#xff09;自动换行 PrintWriter package com.itheima.println;import java.io.FileInputStream; import java.io.PrintStream; import java.io.PrintWriter;public class Test2 {public static void main(String[] arg…