网站运营与管理的一个目的,泉港区住房和城乡规划建设局网站,wordpress界面主题,wordpress 多级分类结合备份binlog恢复数据。场景#xff1a;昨天晚上做了全备#xff0c;今天上午用户不小心误删除某张表。解决方案#xff1a;不建议在原生产环境直接恢复#xff0c;建议在另一台机器恢复全库日志#xff0c;然后导入到生产环境。1) 创建表select now();create table itp…结合备份binlog恢复数据。场景昨天晚上做了全备今天上午用户不小心误删除某张表。解决方案不建议在原生产环境直接恢复建议在另一台机器恢复全库日志然后导入到生产环境。1) 创建表select now();create table itpuxfg1 (id int(10) unsigned not null auto_increment,name varchar(16) not null,sex enum(m,w) not null default m,age tinyint(3) unsigned not null,primary key (id)) engineinnodb default charsetutf8;insert into itpux.itpuxfg1(name,sex,age) values(itpux1,w,21),(itpux2,m,22),(itpux3,w,23),(itpux4,m,24),(itpux5,w,25);commit;select * from itpux.itpuxfg1;2)做备份 逻辑备份mysqldump -uroot -p -F -R --all-databases alldb_bak.sql3) 模拟上午的业务操作show master status; -- 154select now(); -- 2018-04-27 06:27:40update itpux.itpuxfg1 set nameitpux04 where id4;commit;select * from itpux.itpuxfg1;select now(); -- 2018-04-27 06:28:03update itpux.itpuxfg1 set nameitpux05 where id5;commit;select * from itpux.itpuxfg1;show master status; -- 8904) 中午的误删除select now(); -- 2018-04-27 06:29:00drop table itpuxfg1;select * from itpux.itpuxfg1;show master status; -- 10785) 在另一台机器恢复(我的案例在本地生产不要在本地)show master status;通过这个文件名向前备份需要的binlog--记得拷贝binlog日志show binlog events in itpuxdb-binlog.000003;mysqlbinlog itpuxdb-binlog.000003 |grep DROP TABLEmysqlbinlog itpuxdb-binlog.000003 |grep itpuxfg1(注意日志 两个不同的版本 请区分)演示把itpux 库删除drop database itpux;恢复先创建数据库mysql create database itpux default character set utf8; -- 如果不清楚条件建议在原库查询show create database mysql;mysql -uroot -p -o itpux alldb_bak.sql-- 恢复后查不到今天上午更新的记录mysql show tables;-- 通过binlog 日志增量恢复表删除之前[rootmysqldb binlog]# mysqlbinlog -vv --start-position219 --stop-position913 --databaseitpux itpuxdb-binlog.000001 sa.sql-- 恢复这张表到原库里面先从另外的库里备份这张表mysqldump -uroot -p itpux itpuxfg1 sa.sql再把生产库直接恢复(原来的库中的表是已经被删除掉了)mysql -uroot -p itpux sa.sqlmysql select * from itpuxfg1;1)恢复到这张表到源库里mysqldump -uroot -p itpux itpuxfg1 sa.sql相关推荐