MySQL 备份和恢复
[mysqld] log-bin=mysql-bin # server-id=1 # replication时用到
innodb_flush_log_at_trx_commit=1
sync_binlog=1
shell>mysqldump --single-transaction --flush-logs --master-data=2 \
--all-databases > backup_sunday_1_PM.sql
-- Position to start replication or point-in-time recovery from -- CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000006‘,MASTER_LOG_POS=4;
-
输出的.sql文件包含mysql-bin.000006之前所有的数据库改变。
-
在这次full backup之后,所有的数据库改变都将会记录到mysql-bin.000006以及后续number的bin-log中。
shell> mysqladmin flush-logs
shell> mysql < backup_sunday_1_PM.sql
shell> mysqlbinlog mysql-bin.000006 mysql-bin.000007 | mysql
shell> mysqlbinlog mysql-bin.000006
| more
shell> mysqlbinlog mysql-bin.000006
> temp.sql
#141213 3:12:15 server id 1
use `test`/*!*/;
SET TIMESTAMP=1418469135/*!*/;
insert into user_list (name, age) values (‘haha‘, 50)
shell> mysqlbinlog --stop-datetime="2012-12-12 12:12:12" mysql-bin.000006 | mysql
shell> mysqlbinlog --start-datetime="2012-12-12 12:12:12" mysql-bin.000006 | mysql
shell> mysqlbinlog --stop-position=120 mysql-bin.000006 | mysql
shell> mysqlbinlog --start-position=100 mysql-bin.000006 | mysql
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。