Mysql update误操作恢复

update忘加where条件误操作
从binlog找到那条语句:
[root@xxx]#/usr/local/mysql/bin/mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysq-bin.xxxx | grep -B 15 'failure' | more /*|*/;

导出binlog
[root@xxx]#/usr/local/mysql/bin/mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysq-bin.xxxx | sed -n '/# at 249/,/COMMIT/p' > /opt/1.txt

将binlog转换为sql语句
[root@xxx]#sed '/WHERE/{:a;N;/SET/!ba;s/\([^\n]*\)\n\(.*\)\n\(.*\)/\3\n\2\n\1/}' 1.txt
| sed -r '/WHERE/{:a;N;/@4/!ba;s/### @2.*//g}'
| sed 's/### //g;s/\/\*.*/,/g'
| sed '/WHERE/{:a;N;/@1/!ba;s/,/;/g};s/#.*//g;s/COMMIT,//g'
| sed '/^$/d' > ./recover.sql

mysql> source /opt/recovery.sql
mysql> select * from test;


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9522838/viewspace-2284994/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9522838/viewspace-2284994/

你可能感兴趣的:(数据库)