mysql binlog 查找
接着昨天的mysql delete还原,我现在大致的思路是,从还原一个最近备份的表,然后再从日志文件里面找,可是如果日志文件非常大的情况下找起来非常的麻烦,我想能不能通过linux sed 或者grep 找出和表相关的操作, grep 'xxx' 1.sql 值能列出和xxx相关的操作,但是列不出时间等等。下面是日志文件的部分,我现在想得到和xxx相关的东西包括时间等,例如:其他的不想要,这个正则表达式怎么写??
BEGIN
/*!*/;
# at 170
#100824 11:26:27 server id 1 end_log_pos 277 Query thread_id=1 exec_time=0 error_code=0
use test_dbo/*!*/;
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 277
#100824 11:26:27 server id 1 end_log_pos 304 Xid = 38
COMMIT/*!*/;
# at 304
#100824 11:26:27 server id 1 end_log_pos 376 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
BEGIN
/*!*/;
# at 376
#100824 11:26:27 server id 1 end_log_pos 483 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 483
#100824 11:26:27 server id 1 end_log_pos 510 Xid = 54
COMMIT/*!*/;
所有的日志文件
BEGIN
/*!*/;
# at 170
#100824 11:26:27 server id 1 end_log_pos 277 Query thread_id=1 exec_time=0 error_code=0
use test_dbo/*!*/;
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 277
#100824 11:26:27 server id 1 end_log_pos 304 Xid = 38
COMMIT/*!*/;
# at 304
#100824 11:26:27 server id 1 end_log_pos 376 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
BEGIN
/*!*/;
# at 376
#100824 11:26:27 server id 1 end_log_pos 483 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 483
#100824 11:26:27 server id 1 end_log_pos 510 Xid = 54
COMMIT/*!*/;
# at 510
#100824 11:40:13 server id 1 end_log_pos 582 Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1282621213/*!*/;
BEGIN
/*!*/;
# at 2353
#100825 9:13:49 server id 1 end_log_pos 2443 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698829/*!*/;
delete from ddd
/*!*/;
# at 2443
#100825 9:13:49 server id 1 end_log_pos 2470 Xid = 202
COMMIT/*!*/;
# at 2470
#100825 9:13:53 server id 1 end_log_pos 2542 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698833/*!*/;
BEGIN
/*!*/;
# at 2542
#100825 9:13:53 server id 1 end_log_pos 2639 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698833/*!*/;
delete from zzz
/*!*/;
# at 2639
#100825 9:13:53 server id 1 end_log_pos 2666 Xid = 206
COMMIT/*!*/;
# at 2666
#100825 9:13:54 server id 1 end_log_pos 2738 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698834/*!*/;
BEGIN
/*!*/;
# at 2738
#100825 9:13:54 server id 1 end_log_pos 2835 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698834/*!*/;
delete from zzz
/*!*/;
# at 2835
#100825 9:13:54 server id 1 end_log_pos 2862 Xid = 207
COMMIT/*!*/;
# at 2862
#100825 9:15:34 server id 1 end_log_pos 2954 Query thread_id=8 exec_time=1 error_code=0
SET TIMESTAMP=1282698934/*!*/;
DROP TABLE `qqq`
/*!*/;
DELIMITER ;
BEGIN
/*!*/;
# at 170
#100824 11:26:27 server id 1 end_log_pos 277 Query thread_id=1 exec_time=0 error_code=0
use test_dbo/*!*/;
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 277
#100824 11:26:27 server id 1 end_log_pos 304 Xid = 38
COMMIT/*!*/;
# at 304
#100824 11:26:27 server id 1 end_log_pos 376 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
BEGIN
/*!*/;
# at 376
#100824 11:26:27 server id 1 end_log_pos 483 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 483
#100824 11:26:27 server id 1 end_log_pos 510 Xid = 54
COMMIT/*!*/;
所有的日志文件
BEGIN
/*!*/;
# at 170
#100824 11:26:27 server id 1 end_log_pos 277 Query thread_id=1 exec_time=0 error_code=0
use test_dbo/*!*/;
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 277
#100824 11:26:27 server id 1 end_log_pos 304 Xid = 38
COMMIT/*!*/;
# at 304
#100824 11:26:27 server id 1 end_log_pos 376 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
BEGIN
/*!*/;
# at 376
#100824 11:26:27 server id 1 end_log_pos 483 Query thread_id=3 exec_time=658 error_code=0
SET TIMESTAMP=1282620387/*!*/;
update xxx set ChineseName='abc'
/*!*/;
# at 483
#100824 11:26:27 server id 1 end_log_pos 510 Xid = 54
COMMIT/*!*/;
# at 510
#100824 11:40:13 server id 1 end_log_pos 582 Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1282621213/*!*/;
BEGIN
/*!*/;
# at 2353
#100825 9:13:49 server id 1 end_log_pos 2443 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698829/*!*/;
delete from ddd
/*!*/;
# at 2443
#100825 9:13:49 server id 1 end_log_pos 2470 Xid = 202
COMMIT/*!*/;
# at 2470
#100825 9:13:53 server id 1 end_log_pos 2542 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698833/*!*/;
BEGIN
/*!*/;
# at 2542
#100825 9:13:53 server id 1 end_log_pos 2639 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698833/*!*/;
delete from zzz
/*!*/;
# at 2639
#100825 9:13:53 server id 1 end_log_pos 2666 Xid = 206
COMMIT/*!*/;
# at 2666
#100825 9:13:54 server id 1 end_log_pos 2738 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698834/*!*/;
BEGIN
/*!*/;
# at 2738
#100825 9:13:54 server id 1 end_log_pos 2835 Query thread_id=8 exec_time=0 error_code=0
SET TIMESTAMP=1282698834/*!*/;
delete from zzz
/*!*/;
# at 2835
#100825 9:13:54 server id 1 end_log_pos 2862 Xid = 207
COMMIT/*!*/;
# at 2862
#100825 9:15:34 server id 1 end_log_pos 2954 Query thread_id=8 exec_time=1 error_code=0
SET TIMESTAMP=1282698934/*!*/;
DROP TABLE `qqq`
/*!*/;
DELIMITER ;
...全文
相关推荐
Mysql binlog查看工具
简单好用的mysql binlog查看工具 采集于网络。
MySQL利用binlog恢复库表
利用binlog恢复库表,要求如下: 1. 启用binlog日志 2. 创建db1库tb1表,插入3条记录 3. 删除tb1表中刚插入的3条记录 4. 使用mysqlbinlog恢复删除的3条记录
mysql开启binlog.docx
一、什么是binlog Mysql的binlog就是mysql记录数据库事物的日志,类似于Oracle的重做日志,arterybase的WAL日志,这些日志记录了数据库的事物信息,例如对数据的增删改查操作,每一条操作都会记录到binlog中,所以binlog配合数据库全备份是可以把数据库恢复到任意时间点的好工具,但mysql默认情况下可能没有开启,需要在my.cnf中配置一下。
Mysql Binlog快速遍历搜索记录及binlog数据查看的方法
主要介绍了Mysql Binlog快速遍历搜索记录及binlog数据查看的方法的相关资料,需要的朋友可以参考下
mysql数据库恢复 binlog2sql数据库恢复
mysql服务设置; mysql数据库登录;使用binlog2sql工具进行数据bin查询, 数据恢复、操作撤销等;


