{"id":6411,"date":"2024-11-14T13:01:32","date_gmt":"2024-11-14T05:01:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6411\/"},"modified":"2024-11-14T13:01:32","modified_gmt":"2024-11-14T05:01:32","slug":"mysql%e6%9f%a5%e7%9c%8b%e9%94%81%e8%a1%a8%e8%af%ad%e5%8f%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6411\/","title":{"rendered":"mysql\u67e5\u770b\u9501\u8868\u8bed\u53e5"},"content":{"rendered":"<blockquote><p>\n  \u8981\u67e5\u770b mysql \u4e2d\u9501\u5b9a\u7684\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 show processlist \u67e5\u770b\u6b63\u5728\u8fd0\u884c\u7684\u7ebf\u7a0b\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u542b\u9501\u5b9a\u7684\u8868\u4fe1\u606f\u3002\u8981\u89e3\u9501\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 unlock tables\uff0c\u4f46\u5728\u4f7f\u7528\u524d\u9700\u8981\u5148\u63d0\u4ea4\u6216\u56de\u6eda\u672a\u51b3\u7684\u4e8b\u52a1\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/01\/2024080121463128574.jpg\" class=\"aligncenter\" title=\"mysql\u67e5\u770b\u9501\u8868\u8bed\u53e5\u63d2\u56fe\" alt=\"mysql\u67e5\u770b\u9501\u8868\u8bed\u53e5\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u67e5\u770b\u9501\u8868\u8bed\u53e5<\/strong><\/p>\n<p>\u4e3a\u4e86\u67e5\u770b MySQL \u4e2d\u9501\u5b9a\u7684\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SHOW PROCESSLIST<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8be6\u7ec6\u89e3\u91ca\uff1a<\/strong><\/p>\n<p>SHOW PROCESSLIST \u547d\u4ee4\u4f1a\u663e\u793a\u5f53\u524d\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u7ebf\u7a0b\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u9501\u5b9a\u7684\u8868\u3002\u8f93\u51fa\u7ed3\u679c\u4e2d\uff0c\u67e5\u627e\u4ee5\u4e0b\u5173\u952e\u5b57\u6bb5\uff1a<\/p>\n<ul>\n<li> <strong>Info:<\/strong> \u5305\u542b\u6709\u5173\u7ebf\u7a0b\u6b63\u5728\u6267\u884c\u7684\u64cd\u4f5c\u7684\u4fe1\u606f\u3002<\/li>\n<li> <strong>State:<\/strong> \u8868\u793a\u7ebf\u7a0b\u7684\u5f53\u524d\u72b6\u6001\u3002<\/li>\n<li> <strong>Time:<\/strong> \u663e\u793a\u7ebf\u7a0b\u5df2\u8fd0\u884c\u7684\u65f6\u95f4\u3002<\/li>\n<li> <strong>Command:<\/strong> \u6307\u793a\u7ebf\u7a0b\u6b63\u5728\u6267\u884c\u7684\u547d\u4ee4\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u9501\u8868\uff1a<\/strong><\/p>\n<p>\u8981\u89e3\u9501\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>UNLOCK TABLES<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong> \u5728\u4f7f\u7528 UNLOCK TABLES \u547d\u4ee4\u4e4b\u524d\uff0c\u5fc5\u987b\u5148 COMMIT \u6216 ROLLBACK \u4efb\u4f55\u672a\u51b3\u7684\u4e8b\u52a1\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u8981\u67e5\u770b\u5f53\u524d\u9501\u5b9a\u8868\u7684\u7ebf\u7a0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SHOW PROCESSLIST WHERE Info LIKE \"%locked%\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u663e\u793a\u6240\u6709\u5305\u542b &#8220;locked&#8221; \u5b57\u7b26\u4e32\u7684\u8fdb\u7a0b\uff0c\u6307\u793a\u9501\u5b9a\u8868\u3002<\/p>\n<p><strong>\u5176\u4ed6\u65b9\u6cd5\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>MySQL Enterprise Monitor (MEM):<\/strong> MEM \u662f MySQL \u63d0\u4f9b\u7684\u56fe\u5f62\u754c\u9762\u5de5\u5177\uff0c\u5141\u8bb8\u60a8\u76d1\u63a7\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u5305\u62ec\u67e5\u770b\u9501\u5b9a\u7684\u8868\u3002<\/li>\n<li> <strong>\u7b2c\u4e09\u65b9\u5de5\u5177:<\/strong> \u4e5f\u6709\u7b2c\u4e09\u65b9\u5de5\u5177\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u9501\u5b9a\u7684\u8868\uff0c\u4f8b\u5982 pt-showlocks\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u67e5\u770b\u9501\u8868\u8bed\u53e5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u67e5\u770b mysql \u4e2d\u9501\u5b9a\u7684\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 show processlist \u67e5\u770b\u6b63\u5728\u8fd0\u884c\u7684\u7ebf\u7a0b\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u542b\u9501\u5b9a\u7684\u8868\u4fe1\u606f\u3002\u8981\u89e3\u9501\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 unlock tables\uff0c\u4f46\u5728\u4f7f\u7528\u524d\u9700\u8981\u5148\u63d0\u4ea4\u6216\u56de\u6eda\u672a\u51b3\u7684\u4e8b\u52a1\u3002 MySQL \u67e5\u770b\u9501\u8868\u8bed\u53e5 \u4e3a\u4e86\u67e5\u770b MySQL \u4e2d\u9501\u5b9a\u7684\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a SHOW PROCESSLIST \u767b\u5f55\u540e\u590d\u5236 \u8be6\u7ec6\u89e3\u91ca\uff1a SHOW PROCESSLIST \u547d\u4ee4\u4f1a\u663e\u793a\u5f53\u524d\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u7ebf\u7a0b\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u9501\u5b9a\u7684\u8868\u3002\u8f93\u51fa\u7ed3\u679c\u4e2d\uff0c\u67e5\u627e\u4ee5\u4e0b\u5173\u952e\u5b57\u6bb5\uff1a Info: \u5305\u542b\u6709\u5173\u7ebf\u7a0b\u6b63\u5728\u6267\u884c\u7684\u64cd\u4f5c\u7684\u4fe1\u606f\u3002 State: \u8868\u793a\u7ebf\u7a0b\u7684\u5f53\u524d\u72b6\u6001\u3002 Time: \u663e\u793a\u7ebf\u7a0b\u5df2\u8fd0\u884c\u7684\u65f6\u95f4\u3002 Command: \u6307\u793a\u7ebf\u7a0b\u6b63\u5728\u6267\u884c\u7684\u547d\u4ee4\u3002 \u89e3\u9501\u8868\uff1a \u8981\u89e3\u9501\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a UNLOCK TABLES \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\uff1a \u5728\u4f7f\u7528 UNLOCK TABLES \u547d\u4ee4\u4e4b\u524d\uff0c\u5fc5\u987b\u5148 COMMIT \u6216 ROLLBACK \u4efb\u4f55\u672a\u51b3\u7684\u4e8b\u52a1\u3002 \u793a\u4f8b\uff1a \u8981\u67e5\u770b\u5f53\u524d\u9501\u5b9a\u8868\u7684\u7ebf\u7a0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a SHOW PROCESSLIST WHERE Info LIKE &#8220;%locked%&#8221; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u663e\u793a\u6240\u6709\u5305\u542b &#8220;locked&#8221; \u5b57\u7b26\u4e32\u7684\u8fdb\u7a0b\uff0c\u6307\u793a\u9501\u5b9a\u8868\u3002 \u5176\u4ed6\u65b9\u6cd5\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6411","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6411"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6411\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}