{"id":302,"date":"2016-03-23T17:05:13","date_gmt":"2016-03-23T09:05:13","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=302"},"modified":"2016-03-23T17:08:46","modified_gmt":"2016-03-23T09:08:46","slug":"%e5%a6%82%e4%bd%95%e5%bc%80%e5%90%afmysql%e7%9a%84%e6%85%a2%e6%9f%a5%e8%af%a2%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=302","title":{"rendered":"\u5982\u4f55\u5f00\u542fMySQL\u7684\u6162\u67e5\u8be2\u65e5\u5fd7"},"content":{"rendered":"<p>\n\t\u5728\u8bb2\u5230\u6027\u80fd\u8c03\u4f18\u65b9\u9762\uff0c\u6211\u60f3\u65e0\u5916\u4e4e\u5c31\u662f3\u4e2a\u65b9\u9762\uff1a<br \/>\n\t<strong>1.\u786c\u4ef6\u8c03\u4f18(\u66ff\u6362\u6709\u95ee\u9898\u7684\u786c\u4ef6)<br \/>\n\t2.\u5bf9\u6570\u636e\u5e93\u914d\u7f6e\u8c03\u4f18<br \/>\n\t3.\u5bf9SQL\u8bed\u53e5\u8fdb\u884c\u8c03\u4f18<\/strong><br \/>\n\t\u7b2c\u4e00\u79cd\u901a\u5e38\u53ef\u4ee5\u8ba9\u4e2d\u592e\u5904\u7406\u5668\uff08CPU\uff09\u6216\u78c1\u76d8\u901f\u5ea6\u52a0\u500d\uff0c\u4e5f\u53ef\u4ee5\u8ba9\u5185\u5b58\u589e\u5927 4 \u5230 8 \u500d\u3002\u4e3b\u8981\u662f\u8ba9\u8d44\u6e90\u6700\u5927\u5316\u7684\u5229\u7528\u3002<br \/>\n\t\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u662f\u5bf9MySQL\u670d\u52a1\u5668\uff08\u4e5f\u79f0\u4e3amysqld\uff09\u8fdb\u884c\u8c03\u4f18\u3002\u5bf9\u8fd9\u4e2a\u8fdb\u7a0b\u8fdb\u884c\u8c03\u4f18\u610f\u5473\u7740\u9002\u5f53\u5730\u5206\u914d\u5185\u5b58\uff0c\u5e76\u8ba9mysqld\u4e86\u89e3\u5c06\u4f1a\u627f\u53d7\u4f55\u79cd\u7c7b\u578b\u7684\u8d1f\u8f7d\u3002\u52a0\u5feb\u78c1\u76d8\u8fd0\u884c\u901f\u5ea6\u4e0d\u5982\u51cf\u5c11\u6240\u9700\u7684\u78c1\u76d8\u8bbf\u95ee\u6b21\u6570\u3002\u786e\u4fddMySQL\u8fdb\u7a0b\u6b63\u786e\u64cd\u4f5c\u5c31\u610f\u5473\u7740\u5b83\u82b1\u8d39\u5728\u670d\u52a1\u67e5\u8be2\u4e0a\u7684\u65f6\u95f4\u8981\u591a\u4e8e\u82b1\u8d39\u5728\u5904\u7406\u540e\u53f0\u4efb\u52a1\uff08\u5982\u5904\u7406\u4e34\u65f6\u78c1\u76d8\u8868\u6216\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6\uff09\u4e0a\u7684\u65f6\u95f4\u3002<br \/>\n\t\u7b2c\u4e09\u79cd\u65b9\u6cd5\u662f\u786e\u4fdd\u589e\u5220\u6539\u67e5\u8fdb\u884c\u4e86\u4f18\u5316\u3002\u8fd9\u610f\u5473\u7740\u5bf9\u8868\u5e94\u7528\u4e86\u6700\u4f18\u7684\u7d22\u5f15\uff0c\u67e5\u8be2\u662f\u6309\u7167\u53ef\u4ee5\u5145\u5206\u5229\u7528MySQL\u529f\u80fd\u7684\u65b9\u5f0f\u6765\u7f16\u5199\u7684\u3002\u5305\u62ecSQL\u8bed\u53e5\u7684\u7f16\u5199\uff0c\u7d22\u5f15\uff0c\u5b58\u50a8\u8fc7\u7a0b\uff0c\u51fd\u6570\u7b49\u7b49\u7684\u4f7f\u7528\u3002<br \/>\n\t\u90a3\u4e48\u5982\u4f55\u53d1\u73b0\u81ea\u5df1\u5199\u7684SQL\u662f\u5426\u9ad8\u6548\u5462\uff1f\u4e0b\u9762\u6559\u4f60\u4e00\u79cd\u6700\u91cd\u8981\u7684\u65b9\u6cd5\uff1a<strong>\u8bb0\u5f55\u6162\u901f\u67e5\u8be2<\/strong>\u3002<br \/>\n\t\u6211\u4eec\u53ef\u4ee5\u914d\u7f6emysqld\u5c06\u8fd9\u4e9b\u6162\u901f\u67e5\u8be2\u8bb0\u5f55\u5230\u9002\u5f53\u547d\u540d\u7684\u6162\u901f\u67e5\u8be2\u65e5\u5fd7\u4e2d\u3002\u7136\u540e\u901a\u8fc7\u5206\u6790\u65e5\u5fd7\u6765\u786e\u5b9a\u54ea\u4e9b\u90e8\u5206\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u4f18\u5316\u3002\u542f\u7528\u6162\u901f\u67e5\u8be2\u65e5\u5fd7\u9700\u8981\u5728my.cnf\u4e2d\u505a\u4e00\u4e0b\u914d\u7f6e\uff1a\n<\/p>\n<pre>\r\n\t[mysqld]\r\n\tlog-slow-queries\r\n\tlong_query_time = 3\r\n\tlog-queries-not-using-indexes<\/pre>\n<p>\n\t\u8fd9\u4e09\u4e2a\u8bbe\u7f6e\u4e00\u8d77\u4f7f\u7528\uff0c\u53ef\u4ee5\u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc73\u79d2\u548c\u6ca1\u6709\u4f7f\u7528\u7d22\u5f15\u7684\u67e5\u8be2\u3002\u6709\u5173log-queries-not-using-indexes\u7684\u914d\u7f6e\u3002\u6211\u4eec\u5fc5\u987b\u4f7f\u7528MySQL4.1\u6216\u66f4\u9ad8\u7248\u672c\u3002\u6162\u901f\u67e5\u8be2\u65e5\u5fd7\u90fd\u4fdd\u5b58\u5728MySQL\u6570\u636e\u76ee\u5f55\u4e2d\uff0c\u540d\u4e3ahostname-slow.log\u3002\u5982\u679c\u5e0c\u671b\u4f7f\u7528\u4e00\u4e2a\u4e0d\u540c\u7684\u540d\u5b57\u6216\u8def\u5f84\uff0c\u53ef\u4ee5\u5728my.cnf\u4e2d\u4f7f\u7528log-slow-queries = \/new\/path\/to\/file \u5b9e\u73b0\u6b64\u76ee\u7684\u3002<br \/>\n\t\u9605\u8bfb\u6162\u901f\u67e5\u8be2\u65e5\u5fd7\u53ef\u4ee5\u901a\u8fc7mysqldumpslow\u547d\u4ee4\u8fdb\u884c\u3002\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u6162\u901f\u67e5\u8be2\u7684\u6392\u5e8f\u540e\u7684\u5217\u8868\uff0c\u5e76\u4e14\u8fd8\u663e\u793a\u4e86\u5b83\u4eec\u5728\u65e5\u5fd7\u6587\u4ef6\u4e2d\u51fa\u73b0\u7684\u6b21\u6570\u3002\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u7279\u6027\u662fmysqldumpslow\u5728\u6bd4\u8f83\u7ed3\u679c\u4e4b\u524d\uff0c\u4f1a\u5220\u9664\u4efb\u4f55\u7528\u6237\u6307\u5b9a\u7684\u6570\u636e\uff0c\u56e0\u6b64\u5bf9\u540c\u4e00\u4e2a\u67e5\u8be2\u7684\u4e0d\u540c\u8c03\u7528\u88ab\u8ba1\u4e3a\u4e00\u6b21\uff1b\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u627e\u51fa\u9700\u8981\u5de5\u4f5c\u91cf\u6700\u591a\u7684\u67e5\u8be2\u3002\n<\/p>\n<p>\n\t&nbsp;<\/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=302\">\u5982\u4f55\u5f00\u542fMySQL\u7684\u6162\u67e5\u8be2\u65e5\u5fd7<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5728\u8bb2\u5230\u6027\u80fd\u8c03\u4f18\u65b9\u9762\uff0c\u6211\u60f3\u65e0\u5916\u4e4e\u5c31\u662f3\u4e2a\u65b9\u9762\uff1a 1.\u786c\u4ef6\u8c03\u4f18(\u66ff\u6362\u6709\u95ee\u9898\u7684\u786c\u4ef6) 2.\u5bf9\u6570\u636e\u5e93\u914d\u7f6e\u8c03\u4f18 3.\u5bf9S [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":156,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[96,95,83,94,97],"class_list":["post-302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-log-slow-queries","tag-long_query_time","tag-mysql","tag-mysqld","tag-mysqldumpslow"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/302","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=302"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/302\/revisions\/304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/media\/156"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}