{"id":4232,"date":"2019-05-11T20:18:03","date_gmt":"2019-05-11T12:18:03","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4232"},"modified":"2019-05-11T20:19:23","modified_gmt":"2019-05-11T12:19:23","slug":"%e8%b5%b0%e7%8b%97%e5%b1%8e%e8%bf%90%e4%ba%86%ef%bc%8cmysql%e5%8d%a0%e7%94%a8%e7%a9%ba%e9%97%b4%e7%ab%9f%e7%84%b6%e8%b6%8a%e5%88%a0%e8%b6%8a%e5%a4%a7","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4232","title":{"rendered":"\u8d70\u72d7\u5c4e\u8fd0\u4e86\uff0cMySQL\u5360\u7528\u7a7a\u95f4\u7adf\u7136\u8d8a\u5220\u8d8a\u5927"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u8bdd\u8bf4\u6709\u4e00\u5929\uff0c\u6211\u5fc3\u8840\u6765\u6f6e\u3002\u767b\u5f55\u963f\u91cc\u4e91\uff0c\u53d1\u73b0 RDS \u5360\u7528\u7684\u7a7a\u95f4\u633a\u5927\u7684\u3002\u60f3\u8d77\u6709\u4e00\u5f20\u8868\uff0c\u5f53\u521d\u8bbe\u8ba1\u7684\u4e0d\u597d\uff0c\u6ca1\u7528\u7684\u6570\u636e\u633a\u591a\u7684\u3002\u5c31\u60f3\u7740\u5220\u9664\u6e05\u7406\u4e00\u90e8\u5206\u6570\u636e\uff0c\u8282\u7ea6\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf4\u505a\u5c31\u505a\uff0c\u4e00\u6761 delete \u8bed\u53e5\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>delete FROM xttblog where day &lt; 2019 and status = 7;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ca1\u60f3\u5230\u610f\u5916\u53d1\u751f\u4e86\uff0c\u5220\u9664\u51e0\u5341\u4e07\u6761\u6570\u636e\u540e\uff0c\u6211\u518d\u53bb\u67e5\u770b RDS \u5360\u7528\u7684\u6570\u636e\u7a7a\u95f4\uff0c\u4e0d\u4ec5\u6ca1\u964d\uff0c\u8fd8\u4e0a\u5347\u4e86\u3002\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\uff1f<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=http:\/\/ww1.sinaimg.cn\/large\/8fa5dcfcly1g2xmtvfxrnj20c9072jry.jpg\" alt=\"\" \/><figcaption>\u51fa\u4e4e\u7a0b\u5e8f\u5458\u7684\u610f\u6599<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u5f88\u591a\u4eba\u90fd\u6ca1\u6709\u6ce8\u610f\u5230\u3002\u5e73\u65f6\u5927\u5bb6\u7684\u5173\u6ce8\u70b9\u53ef\u80fd\u90fd\u4e0d\u5728\u8fd9\u65b9\u9762\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u628a\u8fd9\u4e2a\u6570\u636e\u5220\u9664\u540e\uff0c\u963f\u91cc\u4e91\u7acb\u9a6c\u53d1\u90ae\u4ef6\u62a5\u8b66\uff0c\u8bf4\u6211\u4eec\u7684 RDS \u5b58\u50a8\u7a7a\u95f4\u8fc7\u5927\uff0c\u6ca1\u529e\u6cd5\uff0c\u5f53\u521d\u77e5\u8bc6\u6c34\u5e73\u6709\u9650\u3002\u5c31\u53c8\u82b1\u516c\u53f8\u7684\u94b1\uff0c\u5347\u7ea7\u4e86\u5b58\u50a8\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u95ee\u9898\u4e00\u76f4\u56f0\u60d1\u7740\u6211\uff0c\u76f4\u5230\u4e24\u5e74\u524d\u770b\u4e86\u300a\u9ad8\u6027\u80fdMySQL\u300b\u3002\u800c\u4eca\u5929\u521a\u597d\u53c8\u6709\u4e00\u4e2a\u7f51\u53cb\u79c1\u4fe1\u6211\uff0c\u6211\u60f3\u8d77\u4e86\u8fd9\u4ef6\u4e8b\u3002\u6240\u4ee5\uff0c\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u89e3\u60d1\u4e00\u4e0b\uff0c\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u4e2a\u5c31\u662f\u7f51\u4e0a\u5f88\u591a\u4eba\u6240\u8bf4\u7684\u90a3\u6837\uff0c\u8fd9\u662f\u4e00\u4e2aMySQL\u7684BUG\uff0c\u76f4\u5230MySQL 5.7 \u7248\u672c\u624d\u89e3\u51b3\u3002\u7531\u4e8e\u6211\u4eec\u5f53\u521d\u9009\u7684\u662f MySQL 5.6 \u7684\u7248\u672c\uff0c\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\u540e\uff0c\u4e5f\u54a8\u8be2\u4e86\u963f\u91cc\u4e91\u3002\u4f46\u662f\u963f\u91cc\u4e91\u7ed9\u51fa\u7684\u7b54\u590d\u662f\u53ea\u80fd\u8fdb\u884c\u6570\u636e\u8fc1\u79fb\uff0c\u867d\u7136MySQL5.7\u7248\u672c\uff0c\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\u963f\u91cc\u4e91\u7684MySQL5.6\u7684\u7248\u672c\u5e76\u4e0d\u80fd\u76f4\u63a5\u5347\u7ea7\u52305.7\u3002\u800c\u8fc1\u79fb\u6570\u636e\u5e93\u4e5f\u592a\u6d6a\u8d39\u65f6\u95f4\u548c\u7cbe\u529b\u4e86\uff0c\u641e\u4e0d\u597d\uff0c\u518d\u628a\u4e3b\u8981\u6570\u636e\u7ed9\u4e22\u5931\u4e86\u3002BOSS \u975e\u5241\u4e86\u6211\u4e0d\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u4e2a\u6211\u8981\u8bf4\u7684\u5c31\u662f MySQL 5.6\u4e2d\u9ed8\u8ba4\u662f\u72ec\u7acb\u8868\u7a7a\u95f4\uff0c\u5982\u679c\u91c7\u7528\u72ec\u7acb\u8868\u5b58\u50a8\u6a21\u5f0f\uff0cdata \u4e2d\u8fd8\u4f1a\u4ea7\u751f report_site_day.ibd \u8fd9\u7c7b\u6587\u4ef6\uff08\u5b58\u50a8\u6570\u636e\u4fe1\u606f\u548c\u7d22\u5f15\u4fe1\u606f\uff09\u3002\u800c\u5220\u9664\u7684\u65f6\u5019\uff0c\u5b83\u4e0d\u4f1a\u88ab\u5220\u9664\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e09\u4e2a\u5c31\u662f MySQL \u5bf9\u4e8e\u5220\u9664\u7684\u529f\u80fd\u7684\u5e95\u5c42\u5b9e\u73b0\uff0c\u5e76\u4e0d\u662f\u5927\u5bb6\u60f3\u8c61\u7684\u90a3\u6837\uff0c\u6267\u884c delete \u5c31\u771f\u7684\u7ed9\u5220\u9664\u4e86\u3002\u800c\u662f\u5f53\u4f60\u4f7f\u7528 delete \u5220\u9664\u7684\u65f6\u5019\uff0cMySQL \u5e76\u6ca1\u6709\u628a\u6570\u636e\u6587\u4ef6\u5220\u9664\uff0c\u800c\u662f\u5c06\u6570\u636e\u6587\u4ef6\u7684\u6807\u8bc6\u4f4d\u5220\u9664\uff0c\u6ca1\u6709\u6574\u7406\u6587\u4ef6\uff0c\u56e0\u6b64\u4e0d\u4f1a\u5f7b\u5e95\u91ca\u653e\u7a7a\u95f4\u3002\u88ab\u5220\u9664\u7684\u6570\u636e\u5c06\u4f1a\u88ab\u4fdd\u5b58\u5728\u4e00\u4e2a\u94fe\u63a5\u6e05\u5355\u4e2d\uff0c\u5f53\u6709\u65b0\u6570\u636e\u5199\u5165\u7684\u65f6\u5019\uff0cMySQL \u4f1a\u5229\u7528\u8fd9\u4e9b\u5df2\u5220\u9664\u7684\u7a7a\u95f4\u518d\u5199\u5165\u3002\u5373\uff0c\u5220\u9664\u64cd\u4f5c\u4f1a\u5e26\u6765\u4e00\u4e9b\u6570\u636e\u788e\u7247\uff0c\u6b63\u662f\u8fd9\u4e9b\u788e\u7247\u5728\u5360\u7528\u786c\u76d8\u7a7a\u95f4\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=http:\/\/ww1.sinaimg.cn\/large\/8fa5dcfcly1g2xmwpxyp4j20de0a4tac.jpg\" alt=\"\" \/><figcaption>\u8d8a\u6df1\u5165\u8d8a\u611f\u89c9\u81ea\u5df1\u65e0\u77e5<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u5173\u4e8e\u6570\u636e\u8fc1\u79fb\u4e5f\u4f1a\u5e26\u6765\u4e00\u4e9b\u95ee\u9898\uff0c\u8fd9\u4e2a\u6211\u4eec\u4e0b\u4e00\u7ae0\u518d\u8bf4\u3002\u4eca\u5929\u6211\u5148\u8bf4\u4e00\u4e0b\uff0cMySQL \u5b98\u65b9\u63a8\u8350\u7684 OPTIMIZE TABLE \u547d\u4ee4\u6765\u6e05\u7406\u4f18\u5316\u8868 InnoDB \u7a7a\u95f4\u7684\u505a\u6cd5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OPTIMIZE TABLE \u547d\u4ee4\u7684\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OPTIMIZE [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name [, tbl_name] ...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5177\u4f53\u7684\u7528\u6cd5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- OPTIMIZE TABLE \u6570\u636e\u5e93\u8868\u540d;\nOPTIMIZE TABLE xtt.xttblog;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u8fd9\u6837\u6279\u91cf\u751f\u6210\u4f18\u5316\u6240\u6709\u8868\u7684 SQL\uff0c\u518d\u590d\u5236\u51fa\u6765\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SET group_concat_max_len=200000;\nSELECT GROUP_CONCAT('OPTIMIZE TABLE ',TABLE_NAME SEPARATOR ';') FROM \ninformation_schema.TABLES WHERE TABLE_SCHEMA=SCHEMA();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u8fd8\u53ef\u4ee5\u628a\u8868\u8bbe\u7f6e\u4e3a\u5355\u8868\u5b58\u50a8\u7684\u5f62\u5f0f\uff0c\u8fd9\u6837\u6bcf\u4e2a\u8868\u4e2d\u7684\u6570\u636e\u5355\u72ec\u5b58\u50a8\uff0c\u5728\u5220\u9664\u6570\u636e\u7684\u65f6\u5019\uff0c\u4f1a\u968f\u7740\u6570\u636e\u7684\u5220\u9664\u800c\u91ca\u653e\u5b58\u50a8\u7a7a\u95f4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set global innodb_file_per_table = on<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u81f3\u4e8e\u6570\u636e\u8fc1\u79fb\uff0c\u6211\u4eec\u53ef\u4ee5\u5148\u5907\u4efd\u540e\u5220\u9664\u7136\u540e\u8fdb\u884c\u5bfc\u5165\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -uxttblog -p123456 --all-databases &gt; db.sql \nservice mysql stop \nrm ibdata \nrm \u00d7log\u6587\u4ef6 \nservice mysql start \nmysql -uxttblog -p123456 &lt; db.sql<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u636e\u8fc1\u79fb\u4e5f\u6709\u5f88\u591a\u5751\uff0c\u8fd9\u4e5f\u662f\u6211\u4e0b\u4e00\u7ae0\u60f3\u8bb2\u7684\u3002\u6211\u4eec\u7684\u7ea6\u5b9a\uff0c\u660e\u5929\u89c1\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4232\">\u8d70\u72d7\u5c4e\u8fd0\u4e86\uff0cMySQL\u5360\u7528\u7a7a\u95f4\u7adf\u7136\u8d8a\u5220\u8d8a\u5927<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u8bdd\u8bf4\u6709\u4e00\u5929\uff0c\u6211\u5fc3\u8840\u6765\u6f6e\u3002\u767b\u5f55\u963f\u91cc\u4e91\uff0c\u53d1\u73b0 RDS \u5360\u7528\u7684\u7a7a\u95f4\u633a\u5927\u7684\u3002\u60f3\u8d77\u6709\u4e00\u5f20\u8868\uff0c\u5f53\u521d\u8bbe\u8ba1\u7684\u4e0d\u597d\uff0c\u6ca1\u7528\u7684\u6570\u636e\u633a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[83,580,1913,392,448],"class_list":["post-4232","post","type-post","status-publish","format-standard","hentry","category-sql","tag-mysql","tag-mysql----dba","tag-mysqlhotcopy"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4232"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4232\/revisions"}],"predecessor-version":[{"id":4233,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4232\/revisions\/4233"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}