目录
恢复数据前提条件:在MySQL配置文件 my.cnf 中开启binlog日志:
log-bin=mysql-bin
binlog_format=row #日志格式,可选statement,row,mixed
binlog_row_image = full
server_id=1
expire_logs_days=30 #binlog保存时效 以天为单位,默认0 永不过期,最多只能设置99天
max_binlog_size=1G
查看binlog是否开启:show variables like 'log_%';
查看binlog保存位置:show variables like '%datadir%';
查看当前正在使用的binlog:show master status;
1、delete 误删数据行
如下有一张user表,共有5条数据,本来只想删除id = 1的记录,结果写错成id > 1,误删了4条数据:delete from user where id > 1; 下面来进行恢复:
- 恢复流程: