时间:2021-07-01 10:21:17 帮助过:4人阅读
--stop-datetime
--start-position
--stop-position
[root@node1 data]# mysqlbinlog master-bin.000021
[root@node1 data]# mysqlbinlog --start-position=207 --stop-position=375 master-bin.000021
[root@node1 data]# mysqlbinlog --start-datetime=‘17-02-13 9:06:21‘ master-bin.000021
还可以将其导入一个文件中,然后再将该文件导入另外一个数据库中,就可以按照二进制日志重新执行一遍
[root@node1 data]# mysqlbinlog --start-datetime=‘17-02-13 9:06:21‘ master-bin.000021 >/root/my.sql
mysql> flush logs; 手动进行日志滚动
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| master-bin.000022 | 120 | | | |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
如果我已经将某时刻之前的数据进行了备份,应该删除该时刻之前的二进制日志,从而节省空间
mysql> purge binary logs to ‘master-bin.0000010‘; 将‘master-bin.0000010‘之前的日志全删除
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| master-bin.000022 | 120 | | | |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> show binary logs; 查看当前拥有的二进制日志
+-------------------+-----------+
| Log_name | File_size |
+-------------------+-----------+
| master-bin.000001 | 69435 |
| master-bin.000002 | 1371047 |
| master-bin.000003 | 143 |
| master-bin.000004 | 143 |
| master-bin.000005 | 120 |
| master-bin.000006 | 143 |
| master-bin.000007 | 4836454 |
| master-bin.000008 | 21561 |
| master-bin.000009 | 143 |
| master-bin.000010 | 143 |
| master-bin.000011 | 120 |
| master-bin.000012 | 120 |
| master-bin.000013 | 120 |
| master-bin.000014 | 143 |
| master-bin.000015 | 120 |
| master-bin.000016 | 143 |
| master-bin.000017 | 120 |
| master-bin.000018 | 818 |
| master-bin.000019 | 2220 |
| master-bin.000020 | 4692 |
| master-bin.000021 | 721 |
| master-bin.000022 | 120 |
+-------------------+-----------+
本文出自 “11097124” 博客,请务必保留此出处http://11107124.blog.51cto.com/11097124/1897457
MySQL之日志管理(一)
标签:mysql之日志管理(一)