{"id":163263,"date":"2024-11-04T22:02:21","date_gmt":"2024-11-04T14:02:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/163263\/"},"modified":"2024-11-04T22:02:22","modified_gmt":"2024-11-04T14:02:22","slug":"%e8%a7%a3%e6%b1%bamysql%e4%b8%a6%e7%99%bc%e5%95%8f%e9%a1%8c%e7%9a%84%e5%af%a6%e7%94%a8%e6%8a%80%e5%b7%a7%ef%bc%88mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e8%99%95%e7%90%86%e4%b8%a6%e7%99%bc%e5%95%8f%e9%a1%8c","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/163263\/","title":{"rendered":"\u89e3\u6c7aMySQL\u4e26\u767c\u554f\u984c\u7684\u5be6\u7528\u6280\u5de7\uff08MySQL\u6578\u64da\u5eab\u8655\u7406\u4e26\u767c\u554f\u984c\uff09"},"content":{"rendered":"<h1 id=\"%e8%a7%a3%e6%b1%bamysql%e4%b8%a6%e7%99%bc%e5%95%8f%e9%a1%8c%e7%9a%84%e5%af%a6%e7%94%a8%e6%8a%80%e5%b7%a7%ef%bc%88mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e8%99%95%e7%90%86%e4%b8%a6%e7%99%bc%e5%95%8f%e9%a1%8c-dVdjOrMHCC\">\u89e3\u6c7aMySQL\u4e26\u767c\u554f\u984c\u7684\u5be6\u7528\u6280\u5de7\uff08MySQL\u6578\u64da\u5eab\u8655\u7406\u4e26\u767c\u554f\u984c\uff09<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0cMySQL\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u7136\u800c\uff0c\u96a8\u8457\u7528\u6236\u6578\u91cf\u7684\u589e\u52a0\u548c\u8acb\u6c42\u7684\u589e\u591a\uff0cMySQL\u7684\u4e26\u767c\u8655\u7406\u80fd\u529b\u53ef\u80fd\u6703\u53d7\u5230\u6311\u6230\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u4e00\u4e9b\u5be6\u7528\u7684\u6280\u5de7\uff0c\u4ee5\u5e6b\u52a9\u958b\u767c\u8005\u548c\u7cfb\u7d71\u7ba1\u7406\u54e1\u6709\u6548\u89e3\u6c7aMySQL\u7684\u4e26\u767c\u554f\u984c\u3002<\/p>\n<h2 id=\"1-%e7%90%86%e8%a7%a3mysql%e7%9a%84%e9%8e%96%e6%a9%9f%e5%88%b6-dVdjOrMHCC\">1. \u7406\u89e3MySQL\u7684\u9396\u6a5f\u5236<\/h2>\n<p>MySQL\u4f7f\u7528\u9396\u4f86\u7ba1\u7406\u4e26\u767c\u8a2a\u554f\u6578\u64da\u7684\u60c5\u6cc1\u3002\u4e86\u89e3\u4e0d\u540c\u985e\u578b\u7684\u9396\u662f\u89e3\u6c7a\u4e26\u767c\u554f\u984c\u7684\u7b2c\u4e00\u6b65\u3002MySQL\u4e3b\u8981\u6709\u4ee5\u4e0b\u5e7e\u7a2e\u9396\uff1a<\/p>\n<ul>\n<li><strong>\u884c\u9396\uff08Row Lock\uff09<\/strong>\uff1a\u53ea\u9396\u5b9a\u6b63\u5728\u88ab\u64cd\u4f5c\u7684\u884c\uff0c\u5141\u8a31\u5176\u4ed6\u884c\u7684\u4e26\u767c\u8a2a\u554f\u3002<\/li>\n<li><strong>\u8868\u9396\uff08Table Lock\uff09<\/strong>\uff1a\u9396\u5b9a\u6574\u500b\u8868\uff0c\u9019\u6703\u5c0e\u81f4\u5176\u4ed6\u8acb\u6c42\u7121\u6cd5\u8a2a\u554f\u8a72\u8868\u3002<\/li>\n<li><strong>\u610f\u5411\u9396\uff08Intention Lock\uff09<\/strong>\uff1a\u7528\u65bc\u8868\u9396\u548c\u884c\u9396\u4e4b\u9593\u7684\u5354\u8abf\uff0c\u5e6b\u52a9\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<\/ul>\n<p>\u5728\u8a2d\u8a08\u6578\u64da\u5eab\u6642\uff0c\u61c9\u76e1\u91cf\u4f7f\u7528\u884c\u9396\uff0c\u4ee5\u63d0\u9ad8\u4e26\u767c\u6027\u80fd\u3002<\/p>\n<h2 id=\"2-%e4%bd%bf%e7%94%a8%e9%81%a9%e7%95%b6%e7%9a%84%e4%ba%8b%e5%8b%99%e9%9a%94%e9%9b%a2%e7%b4%9a%e5%88%a5-dVdjOrMHCC\">2. \u4f7f\u7528\u9069\u7576\u7684\u4e8b\u52d9\u9694\u96e2\u7d1a\u5225<\/h2>\n<p>MySQL\u652f\u6301\u591a\u7a2e\u4e8b\u52d9\u9694\u96e2\u7d1a\u5225\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u8b80\u672a\u63d0\u4ea4\uff08Read Uncommitted\uff09<\/strong><\/li>\n<li><strong>\u8b80\u5df2\u63d0\u4ea4\uff08Read Committed\uff09<\/strong><\/li>\n<li><strong>\u53ef\u91cd\u8907\u8b80\uff08Repeatable Read\uff09<\/strong><\/li>\n<li><strong>\u4e32\u884c\u5316\uff08Serializable\uff09<\/strong><\/li>\n<\/ul>\n<p>\u9078\u64c7\u5408\u9069\u7684\u9694\u96e2\u7d1a\u5225\u53ef\u4ee5\u6709\u6548\u6e1b\u5c11\u9396\u7684\u7af6\u722d\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u201c\u8b80\u5df2\u63d0\u4ea4\u201d\u53ef\u4ee5\u907f\u514d\u8b80\u53d6\u672a\u63d0\u4ea4\u7684\u6578\u64da\uff0c\u5f9e\u800c\u6e1b\u5c11\u9396\u7684\u6301\u6709\u6642\u9593\u3002<\/p>\n<h2 id=\"3-%e5%84%aa%e5%8c%96%e6%9f%a5%e8%a9%a2%e6%80%a7%e8%83%bd-dVdjOrMHCC\">3. \u512a\u5316\u67e5\u8a62\u6027\u80fd<\/h2>\n<p>\u67e5\u8a62\u6027\u80fd\u7684\u512a\u5316\u5c0d\u65bc\u63d0\u9ad8\u4e26\u767c\u8655\u7406\u80fd\u529b\u81f3\u95dc\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u512a\u5316\u67e5\u8a62\u7684\u6280\u5de7\uff1a<\/p>\n<ul>\n<li><strong>\u4f7f\u7528\u7d22\u5f15<\/strong>\uff1a\u70ba\u5e38\u7528\u7684\u67e5\u8a62\u5b57\u6bb5\u5275\u5efa\u7d22\u5f15\uff0c\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u901f\u5ea6\u3002<\/li>\n<li><strong>\u907f\u514dSELECT *<\/strong>\uff1a\u53ea\u9078\u64c7\u9700\u8981\u7684\u5b57\u6bb5\uff0c\u6e1b\u5c11\u6578\u64da\u50b3\u8f38\u91cf\u3002<\/li>\n<li><strong>\u4f7f\u7528EXPLAIN\u5206\u6790\u67e5\u8a62<\/strong>\uff1a\u901a\u904eEXPLAIN\u547d\u4ee4\u5206\u6790\u67e5\u8a62\u8a08\u5283\uff0c\u627e\u51fa\u6027\u80fd\u74f6\u9838\u3002<\/li>\n<\/ul>\n<h2 id=\"4-%e5%af%a6%e6%96%bd%e9%80%a3%e6%8e%a5%e6%b1%a0-dVdjOrMHCC\">4. \u5be6\u65bd\u9023\u63a5\u6c60<\/h2>\n<p>\u9023\u63a5\u6c60\u6280\u8853\u53ef\u4ee5\u6709\u6548\u7ba1\u7406\u6578\u64da\u5eab\u9023\u63a5\uff0c\u6e1b\u5c11\u9023\u63a5\u7684\u5efa\u7acb\u548c\u92b7\u6bc0\u6240\u5e36\u4f86\u7684\u958b\u92b7\u3002\u901a\u904e\u4f7f\u7528\u9023\u63a5\u6c60\uff0c\u61c9\u7528\u7a0b\u5e8f\u53ef\u4ee5\u91cd\u7528\u73fe\u6709\u7684\u6578\u64da\u5eab\u9023\u63a5\uff0c\u5f9e\u800c\u63d0\u9ad8\u6027\u80fd\u548c\u4e26\u767c\u8655\u7406\u80fd\u529b\u3002<\/p>\n<h2 id=\"5-%e5%9e%82%e7%9b%b4%e5%92%8c%e6%b0%b4%e5%b9%b3%e6%93%b4%e5%b1%95-dVdjOrMHCC\">5. \u5782\u76f4\u548c\u6c34\u5e73\u64f4\u5c55<\/h2>\n<p>\u7576\u55ae\u4e00\u6578\u64da\u5eab\u5be6\u4f8b\u7121\u6cd5\u6eff\u8db3\u9700\u6c42\u6642\uff0c\u53ef\u4ee5\u8003\u616e\u5782\u76f4\u64f4\u5c55\uff08\u589e\u52a0\u786c\u4ef6\u8cc7\u6e90\uff09\u6216\u6c34\u5e73\u64f4\u5c55\uff08\u589e\u52a0\u66f4\u591a\u7684\u6578\u64da\u5eab\u5be6\u4f8b\uff09\u3002\u9019\u6a23\u53ef\u4ee5\u5206\u6563\u8ca0\u8f09\uff0c\u63d0\u9ad8\u6574\u9ad4\u6027\u80fd\u3002<\/p>\n<h2 id=\"6-%e7%9b%a3%e6%8e%a7%e5%92%8c%e8%aa%bf%e6%95%b4-dVdjOrMHCC\">6. \u76e3\u63a7\u548c\u8abf\u6574<\/h2>\n<p>\u6301\u7e8c\u76e3\u63a7\u6578\u64da\u5eab\u6027\u80fd\u662f\u89e3\u6c7a\u4e26\u767c\u554f\u984c\u7684\u95dc\u9375\u3002\u4f7f\u7528\u5de5\u5177\u5982MySQL\u7684\u6162\u67e5\u8a62\u65e5\u8a8c\u3001\u6027\u80fd\u6a21\u5f0f\uff08Performance Schema\uff09\u7b49\uff0c\u53ef\u4ee5\u5e6b\u52a9\u8b58\u5225\u6027\u80fd\u74f6\u9838\u4e26\u9032\u884c\u8abf\u6574\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-dVdjOrMHCC\">\u7e3d\u7d50<\/h2>\n<p>\u89e3\u6c7aMySQL\u7684\u4e26\u767c\u554f\u984c\u9700\u8981\u5c0d\u6578\u64da\u5eab\u7684\u9396\u6a5f\u5236\u3001\u4e8b\u52d9\u9694\u96e2\u7d1a\u5225\u3001\u67e5\u8a62\u6027\u80fd\u3001\u9023\u63a5\u7ba1\u7406\u4ee5\u53ca\u64f4\u5c55\u7b56\u7565\u6709\u6df1\u5165\u7684\u7406\u89e3\u548c\u5be6\u8e10\u3002\u901a\u904e\u9019\u4e9b\u6280\u5de7\uff0c\u958b\u767c\u8005\u548c\u7cfb\u7d71\u7ba1\u7406\u54e1\u53ef\u4ee5\u6709\u6548\u63d0\u9ad8MySQL\u7684\u4e26\u767c\u8655\u7406\u80fd\u529b\uff0c\u78ba\u4fdd\u61c9\u7528\u7a0b\u5e8f\u7684\u7a69\u5b9a\u6027\u548c\u6027\u80fd\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\u4f86\u652f\u6301\u60a8\u7684MySQL\u6578\u64da\u5eab\u9700\u6c42\uff0c\u9019\u5c07\u6709\u52a9\u65bc\u63d0\u5347\u6574\u9ad4\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u89e3\u6c7aMySQL\u4e26\u767c\u554f\u984c\u7684\u5be6\u7528\u6280\u5de7\uff0c\u63d0\u5347\u6578\u64da\u5eab\u6027\u80fd\uff0c\u78ba\u4fdd\u6578\u64da\u4e00\u81f4\u6027\u8207\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-163263","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=163263"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163263\/revisions"}],"predecessor-version":[{"id":163264,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163263\/revisions\/163264"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=163263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=163263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=163263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}