用mysqlbinlog查出需要查看的数据后,可以用more来查看:
[[email protected] data]# more recover_sakila.sql | grep --ignore-case -E ‘insert‘ -A2 -B2 | grep yoon
如果表名包含yoon_log,yoon_order,只想导出yoon表的话,+个-w
[[email protected] data]# more recover_sakila.sql | grep --ignore-case -E ‘insert‘ -A2 -B2 | grep -w yoon > yoon.sql
insert into yoon(name) values (‘yoon‘)
insert into yoon(name) values (‘aaa‘)
可以清晰的查看出所有的insert into语句,如果语句中含有较长的HTML内容,就无法查出完整的update语句,用以下命令:
cat recover_sakila.sql | grep -i ‘update yoon‘ -A60 -B60 | grep -i ‘update yoon‘ -A60 -B60 > recover_sakila.sql
用sed可以过滤所有语句,不会被截断:
sed -n "/insert into yoon/,/;/p" yoon.sql |sed ‘s#\/\*!\*\/##‘
时间: 2024-11-03 05:37:29