{"id":213,"date":"2026-01-23T06:52:51","date_gmt":"2026-01-23T06:52:51","guid":{"rendered":"https:\/\/blog.gpst.net.cn:4008\/?p=213"},"modified":"2026-01-28T06:24:15","modified_gmt":"2026-01-28T06:24:15","slug":"mysql%e8%bf%90%e7%bb%b4-%e6%b8%85%e7%90%86-mysql-%e4%b8%bb%e5%ba%93%ef%bc%88master%ef%bc%89%e4%b8%8a-10-%e5%a4%a9%e5%89%8d%e7%9a%84%e4%ba%8c%e8%bf%9b%e5%88%b6%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/opshub.com.cn\/?p=213","title":{"rendered":"MySQL\u8fd0\u7ef4\u2014\u2014\u6e05\u7406 MySQL \u4e3b\u5e93\uff08Master\uff09\u4e0a 10 \u5929\u524d\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff08binlog\uff09\u6587\u4ef6"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>PURGE MASTER LOGS BEFORE DATE_SUB(NOW(), INTERVAL 10 DAY);<\/code><\/pre>\n\n\n\n<p>\u624b\u52a8\u6267\u884c <code>PURGE<\/code> \u5bb9\u6613\u9057\u6f0f\uff0c\u5efa\u8bae\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u81ea\u52a8\u6e05\u7406\uff0c\u4e00\u52b3\u6c38\u9038\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># my.cnf \u6216 my.ini\nexpire_logs_days = 10  -- \u81ea\u52a8\u6e05\u740610\u5929\u524d\u7684binlog\uff08MySQL 5.7\u53ca\u4ee5\u4e0b\uff09\nbinlog_expire_logs_seconds = 864000  -- \u81ea\u52a8\u6e05\u740610\u5929\uff08864000\u79d2\uff09\u524d\u7684binlog\uff08MySQL 8.0+\uff0c\u63a8\u8350\uff09<\/code><\/pre>\n\n\n\n<p>\u4fee\u6539\u540e\u91cd\u542f MySQL \u751f\u6548\uff0c\u6216\u52a8\u6001\u751f\u6548\uff08\u65e0\u9700\u91cd\u542f\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- MySQL 5.7\u53ca\u4ee5\u4e0b\nSET GLOBAL expire_logs_days = 10;\n-- MySQL 8.0+\nSET GLOBAL binlog_expire_logs_seconds = 864000;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u624b\u52a8\u6267\u884c PURGE \u5bb9\u6613\u9057\u6f0f\uff0c\u5efa\u8bae\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u81ea\u52a8\u6e05\u7406\uff0c\u4e00\u52b3\u6c38\u9038\uff1a \u4fee\u6539\u540e\u91cd\u542f MySQL \u751f\u6548\uff0c\u6216\u52a8\u6001\u751f\u6548\uff08\u65e0\u9700\u91cd\u542f\uff09\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-8"],"_links":{"self":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=213"}],"version-history":[{"count":1,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":214,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/213\/revisions\/214"}],"wp:attachment":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}