首页 > 代码库 > mysqlbinlog配置和还原数据

mysqlbinlog配置和还原数据

开启mysqlbin-log
================================================================================
[mysqld]
binlog_cache_size = 1M
log-bin = mysql-bin # 默认该文件是存储在datadir中
log_bin_trust_function_creators=1
binlog_format = mixed
binlog-ignore-db = mysql
binlog-ignore-db = test
binlog-ignore-db = information_schema

 

用mysqlbin-log 还原数据
================================================================================
1) 关掉游戏服
2) 彻底清档数据库,以免还原数据冲突
3) 还原全备数据
    CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.013868‘, MASTER_LOG_POS=45635;
4) 还原binlog日志
    mysqlbinlog mysql-bin.013902 > lx.log
    mysqlbinlog --database=mydbName --start-position="1111" mysql-bin.000051 | mysql
    mysqlbinlog --database=mydbName --stop-position="3333" mysql-bin.000052 | mysql
    mysqlbinlog --start-datetime="2012-09-20 8:10:00" --stop-datetim="2012-09-25 07:30:00" | mysql

mysqlbinlog配置和还原数据