日期:2014-05-16 浏览次数:20815 次
[mysqld] . . . server-id=1 //数据库的 id 这个应该默认是1就不用改动 log-bin=log_name //日志文件的名称 binlog-do-db=db_name //记录日志的数据库 binlog-ignore-db=db_name //不记录日志的数据库
mysql> show variables like 'log_bin'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_bin | ON | +---------------+-------+ 1 row in set (0.00 sec)
mysql> show master status\G; *************************** 1. row *************************** File: mysql-bin.000060 Position: 106 Binlog_Do_DB: qwe; Binlog_Ignore_DB: 1 row in set (0.00 sec) ERROR: No query specified mysql>日志开始从106位置开始记录,数据库qwe.
mysql> insert into test(val,data) values(100,'ffff'); Query OK, 1 row affected (0.00 sec) mysql> insert into test(val,data) values(110,'gggg'); Query OK, 1 row affected (0.00 sec) mysql> insert into test(val,data) values(120,'ffff'); Query OK, 1 row affected (0.01 sec) mysql> delete from test where id between 4 and 5; Query OK, 2 rows affected (0.00 sec) mysql> drop table test; Query OK, 0 rows affected (0.01 sec) mysql> show tables; Empty set (0.00 sec)如何恢复刚刚删除数据库的所有信息。
[root@localhost /]# mysqlbinlog mysql-bin.000005 >/root/Desktop/5.txt
at 1214 #111017 16:30:35 server id 1 end_log_pos 1317 Query thread_id=3 exec_time=0 error_code=0 SET TIMESTAMP=1318840235/*!*/; delete from test where id between 4 and 5 /*!*/; # at 1317 #111017 16:30:43 server id 1 end_log_pos 1345 Intvar SET INSERT_ID=7/*!*/; # at 1345 #111017 16:30:43 server id 1 end_log_pos 1450 Query thread_id=3 exec_time=0 error_code=0
[root@localhost var]# mysqlbinlog mysql-bin.000005 --stop-pos=1214 |mysql -uroot -p Enter password: [root@localhost var]# mysqlbinlog mysql-bin.000005 --start-pos=1317 |mysql -uroot -p Enter password: