MySQL恢复,包括binlog位置MASTER_LOG_POS

标签 mysql mysqlbinlog

我像这样运行 MySQL 数据库转储:

mysqldump mydatabase -u root -p --single-transaction --events --routines --quick --master-data=2 --flush-logs --flush-privileges > mydump.sql

这将创建一个转储文件,其中包含以下行:

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000008', MASTER_LOG_POS=120;

这告诉我任何新的更改都会从 mysql-bin.000008 开始记录

然后,在加载转储文件后,我可以像这样加载增量文件(假设在某个时刻也创建了 mysql-bin.000009):

mysqlbinlog mysql-bin.000008 mysql-bin.000009 | mysql -u root -p mydatabase

但是 MASTER_LOG_POS = 120 怎么样?我需要包含它吗?如果需要,如何包含?我的转储命令包含 --flush-logs,因此它应该启动一个全新的文件。

我正在阅读这里https://dev.mysql.com/doc/refman/5.7/en/backup-policy.html在这里https://dev.mysql.com/doc/refman/5.7/en/recovery-from-backups.html

最佳答案

https://dev.mysql.com/doc/refman/5.6/en/mysqlbinlog.html#option_mysqlbinlog_start-position说:

--start-position=N, -j N

Start reading the binary log at the first event having a position equal to or greater than N. This option applies to the first log file named on the command line.

This option is useful for point-in-time recovery.

关于MySQL恢复,包括binlog位置MASTER_LOG_POS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55602849/

相关文章:

MySQL binlog读取

sql - 搜索数据库

php - 仅在更新时长轮询 MySQL 数据库

PHP导入数据-删除记录-导出数据

mysql - 如何使用 Windows 服务自动从主数据库重新同步从数据库?

MySQL RDS 只读副本服务未清除二进制日志

mysql - 在 MySQL Bin Log 中搜索查询

php - DateTime类创建的时间对象是否受用户机器本地时间的影响?

java - 使用 Spring JDBC 模板从数据库检索时间戳值

mysql - 使用 zongji 模块监听 mysql 更改事件不起作用