{"id":806,"date":"2026-11-20T15:01:22","date_gmt":"2026-11-20T07:01:22","guid":{"rendered":"https:\/\/www.db2go.net\/?p=806"},"modified":"2026-11-20T15:01:22","modified_gmt":"2026-11-20T07:01:22","slug":"%e6%b8%85%e9%99%a4mysql%e7%9a%84binlog","status":"publish","type":"post","link":"https:\/\/www.db2go.net\/?p=806","title":{"rendered":"\u6e05\u9664MySQL\u7684binlog"},"content":{"rendered":"<pre><code class=\"line-numbers\">ubuntu@pzkxj:~<span class=\"katex math inline\">df -h\nFilesystem      Size  Used Avail Use% Mounted on\nudev            7.7G     0  7.7G   0% \/dev\ntmpfs           1.6G  1.4M  1.6G   1% \/run\n\/dev\/vda2       178G  161G  9.1G  95% \/\ntmpfs           7.7G   24K  7.7G   1% \/dev\/shm\ntmpfs           5.0M     0  5.0M   0% \/run\/lock\ntmpfs           7.7G     0  7.7G   0% \/sys\/fs\/cgroup\n\/dev\/vdb        196G  147G   40G  79% \/home\/ubuntu\/oh_home_new\ntmpfs           1.6G   48K  1.6G   1% \/run\/user\/1000\nubuntu@pzkxj:~<\/span> docker exec -it mysql-mid mysql -u root -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 1132\nServer version: 8.0.45 MySQL Community Server - GPL\n\nCopyright (c) 2000, 2026, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt;\nmysql&gt; PURGE BINARY LOGS BEFORE NOW() - INTERVAL 1 DAY;\nQuery OK, 0 rows affected (0.08 sec)\n\nmysql&gt; SHOW BINARY LOGS;\n+---------------+------------+-----------+\n| Log_name      | File_size  | Encrypted |\n+---------------+------------+-----------+\n| binlog.000043 | 1074243608 | No        |\n| binlog.000044 | 1074953561 | No        |\n| binlog.000045 | 1074228211 | No        |\n| binlog.000046 | 1073742657 | No        |\n| binlog.000047 | 1074293932 | No        |\n| binlog.000048 | 1074058862 | No        |\n| binlog.000049 | 1075129056 | No        |\n| binlog.000050 | 8562452881 | No        |\n| binlog.000051 |  170348497 | No        |\n| binlog.000052 | 1075075806 | No        |\n| binlog.000053 | 1074075977 | No        |\n| binlog.000054 | 1074797176 | No        |\n| binlog.000055 | 1074730552 | No        |\n| binlog.000056 | 1073742280 | No        |\n| binlog.000057 | 1074626601 | No        |\n| binlog.000058 | 1075252954 | No        |\n| binlog.000059 | 1074548328 | No        |\n| binlog.000060 | 1073745787 | No        |\n| binlog.000061 | 1074594475 | No        |\n| binlog.000062 | 1073744666 | No        |\n| binlog.000063 | 1073838945 | No        |\n| binlog.000064 | 1074231367 | No        |\n| binlog.000065 | 1073742096 | No        |\n| binlog.000066 | 1074661101 | No        |\n| binlog.000067 | 1074971025 | No        |\n| binlog.000068 | 1074275023 | No        |\n| binlog.000069 | 1073742686 | No        |\n| binlog.000070 | 1073741956 | No        |\n| binlog.000071 | 1074101497 | No        |\n| binlog.000072 |  363448582 | No        |\n+---------------+------------+-----------+\n30 rows in set (0.00 sec)\n\nmysql&gt; PURGE BINARY LOGS BEFORE NOW() - INTERVAL 1 HOUR;\nQuery OK, 0 rows affected (1.01 sec)\n\nmysql&gt; SHOW BINARY LOGS;\n+---------------+------------+-----------+\n| Log_name      | File_size  | Encrypted |\n+---------------+------------+-----------+\n| binlog.000071 | 1074101497 | No        |\n| binlog.000072 |  372853013 | No        |\n+---------------+------------+-----------+\n2 rows in set (0.01 sec)\n\nmysql&gt; exit\nBye\nubuntu@pzkxj:~<span class=\"katex math inline\">df -h\nFilesystem      Size  Used Avail Use% Mounted on\nudev            7.7G     0  7.7G   0% \/dev\ntmpfs           1.6G  1.4M  1.6G   1% \/run\n\/dev\/vda2       178G  106G   65G  63% \/\ntmpfs           7.7G   24K  7.7G   1% \/dev\/shm\ntmpfs           5.0M     0  5.0M   0% \/run\/lock\ntmpfs           7.7G     0  7.7G   0% \/sys\/fs\/cgroup\n\/dev\/vdb        196G  147G   40G  79% \/home\/ubuntu\/oh_home_new\ntmpfs           1.6G   48K  1.6G   1% \/run\/user\/1000\nubuntu@pzkxj:~<\/span> docker exec -it mysql-mid mysql -u root -p\nEnter password:\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 1135\nServer version: 8.0.45 MySQL Community Server - GPL\n\nCopyright (c) 2000, 2026, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt; SET GLOBAL binlog_expire_logs_seconds = 3600;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql&gt; exit\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ubuntu@pzkxj:~df -h Filesystem Size Used Avail Use% Mou&hellip;<\/p>\n <a href=\"https:\/\/www.db2go.net\/?p=806\" title=\"\u6e05\u9664MySQL\u7684binlog\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">\u6e05\u9664MySQL\u7684binlog<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[5],"tags":[],"class_list":["entry","author-suredandan","post-806","post","type-post","status-publish","format-standard","category-mysql"],"views":7,"_links":{"self":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=806"}],"version-history":[{"count":1,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":807,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/806\/revisions\/807"}],"wp:attachment":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}