当前位置:网站首页>Mysql-数据丢失,分析binlog日志文件
Mysql-数据丢失,分析binlog日志文件
2022-07-06 21:10:00 【小蜗牛的路】
场景:测试环境中发现少了一部分应该存在的业务数据
a表关联的b表业务数据有28日的数据,但是a表却没有,故去mysql日志查看原因!
属账号的general_log文件存放的目录
mysql> SHOW VARIABLES LIKE 'gen%';
+----------------------------------+----------------------------+
| Variable_name | Value |
+----------------------------------+----------------------------+
| general_log | OFF |
| general_log_file | /var/lib/mysql/server6.log |
| generated_random_password_length | 20 |
+----------------------------------+----------------------------+
3 rows in set (0.01 sec)
然后可以到对应的general_log目录下去看执行日志。
查看binlog
命令行登录数据库:mysql -uroot -p123456
show binary logs;
mysql> show binary logs
-> ;
+---------------+-----------+-----------+
| Log_name | File_size | Encrypted |
+---------------+-----------+-----------+
| binlog.000001 | 385141819 | No |
+---------------+-----------+-----------+
如果需要查询2022-06-28 00:00:00到2022-06-28 23:59:50 数据库为test的操作日志,输入如下命令将数据写入到一个备用的txt即可
mysqlbinlog --no-defaults --database=test --base64-output=decode-rows -v --start-datetime="2022-06-28 00:00:00" --stop-datetime="2022-06-28 23:59:50" binlog.000001 > test.txt;
--base64-output=decode-rows -v
参数:
- base64-output,可以控制输出语句输出base64编码的BINLOG语句;
- decode-rows:选项将把基于行的事件解码成一个SQL语句
通过vi命令,/关键字 查询相关sql
如图:
查看日志,原来该表在29日9:55:41秒被删掉后有重新创建了,所有业务数据丢失!!!
Binlog解析技巧
- 尽可能在从库解析,避免对主库造成影响
- 先粗略定位涉及相关的库表操作的binlog,再单独解析对应的binlog中的数据
- 在解析DDL时无需加
-v
输出详细信息(加快解析速度) - 如果开启了
binlog_rows_query_log_events
参数,需要用-vv
参数才可显示具体的SQL语句
边栏推荐
- 21. (article ArcGIS API for JS) ArcGIS API for JS rectangular acquisition (sketchviewmodel)
- Class常量池与运行时常量池
- On file uploading of network security
- QT 使用QToolTip 鼠标放上去显示文字时会把按钮的图片也显示了、修改提示文字样式
- 23. (ArcGIS API for JS) ArcGIS API for JS ellipse collection (sketchviewmodel)
- Clock in during winter vacation
- 再AD 的 界面顶部(菜单栏)创建常用的快捷图标
- 未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
- API data interface of A-share index component data
- ggplot 分面的细节调整汇总
猜你喜欢
【DPDK】dpdk样例源码解析之三:dpdk-l3fwd_001
预处理——插值
Que savez - vous de la sérialisation et de l'anti - séquence?
Introduction to opensea platform developed by NFT trading platform (I)
[development software] tilipa Developer Software
codeforces每日5题(均1700)-第七天
Huawei and Xiaomi "copy each other"
1.19.11.SQL客户端、启动SQL客户端、执行SQL查询、环境配置文件、重启策略、自定义函数(User-defined Functions)、构造函数参数
When QT uses qtooltip mouse to display text, the picture of the button will also be displayed and the prompt text style will be modified
Calculation of time and space complexity (notes of runners)
随机推荐
海思3559万能平台搭建:RTSP实时播放的支持
本机mysql
QT 打开文件 使用 QFileDialog 获取文件名称、内容等
【安全攻防】序列化与反序列,你了解多少?
Force buckle ----- path sum III
Docker部署Mysql8的实现步骤
R data analysis: how to predict Cox model and reproduce high score articles
About Confidence Intervals
[leetcode] 700 and 701 (search and insert of binary search tree)
Kotlin Android environment construction
Gpt-3 is a peer review online when it has been submitted for its own research
AVL树插入操作与验证操作的简单实现
Ubuntu 20 installation des enregistrements redisjson
ubuntu20安装redisjson记录
24. (ArcGIS API for JS) ArcGIS API for JS point modification point editing (sketchviewmodel)
The true face of function pointer in single chip microcomputer and the operation of callback function
About Estimation Statistics
Can the applet run in its own app and realize live broadcast and connection?
PHP lightweight Movie Video Search Player source code
运算放大器应用汇总1