{"id":6515,"date":"2024-11-14T11:52:25","date_gmt":"2024-11-14T03:52:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6515\/"},"modified":"2024-11-14T11:52:25","modified_gmt":"2024-11-14T03:52:25","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e5%88%a0%e9%99%a4%e9%87%8d%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6515\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93"},"content":{"rendered":"<blockquote><p>\n  mysql \u4e2d\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u7684\u8fc7\u7a0b\u5982\u4e0b\uff1a\u4f7f\u7528\u67e5\u8be2\u8bc6\u522b\u91cd\u590d\u6570\u636e\u5e93\u3002\u4f7f\u7528 drop database \u8bed\u53e5\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u3002\u4f7f\u7528 show databases \u9a8c\u8bc1\u91cd\u590d\u6570\u636e\u5e93\u662f\u5426\u5df2\u5220\u9664\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080519370849719.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5220\u9664 MySQL \u4e2d\u7684\u91cd\u590d\u6570\u636e\u5e93<\/strong><\/p>\n<p>MySQL \u4e2d\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u8bc6\u522b\u91cd\u590d\u6570\u636e\u5e93\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bc6\u522b\u91cd\u590d\u7684\u6570\u636e\u5e93\uff1a<\/p>\n<pre>SELECT COUNT(DISTINCT database_name) \nFROM information_schema.schemata \nGROUP BY database_name \nHAVING COUNT(*) &gt; 1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8be5\u67e5\u8be2\u5c06\u8fd4\u56de\u91cd\u590d\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 DROP DATABASE \u8bed\u53e5\u5220\u9664\u91cd\u590d\u7684\u6570\u636e\u5e93\uff1a<\/p>\n<pre>DROP DATABASE &lt;database_name&gt;;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u66ff\u6362 \u4e3a\u91cd\u590d\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 <\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5220\u9664\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 SHOW DATABASES; \u8bed\u53e5\u9a8c\u8bc1\u91cd\u590d\u6570\u636e\u5e93\u662f\u5426\u5df2\u5220\u9664\uff1a<\/p>\n<pre>SHOW DATABASES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\u4e0d\u5e94\u518d\u5305\u542b\u91cd\u590d\u7684\u6570\u636e\u5e93\u3002<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u5220\u9664\u6570\u636e\u5e93\u4e4b\u524d\uff0c\u8bf7\u5907\u4efd\u6570\u636e\uff0c\u56e0\u4e3a\u8be5\u64cd\u4f5c\u662f\u4e0d\u53ef\u9006\u7684\u3002<\/li>\n<li>\u5982\u679c\u6570\u636e\u5e93\u4e2d\u5305\u542b\u8868\u6216\u5176\u4ed6\u5bf9\u8c61\uff0c\u5728\u5220\u9664\u6570\u636e\u5e93\u4e4b\u524d\u5fc5\u987b\u5148\u5220\u9664\u8fd9\u4e9b\u5bf9\u8c61\u3002<\/li>\n<li>\u4f7f\u7528 -f \u9009\u9879\u5f3a\u5236\u5220\u9664\u6570\u636e\u5e93\uff0c\u5373\u4f7f\u8be5\u6570\u636e\u5e93\u4e0d\u4e3a\u7a7a\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u600e\u4e48\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\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>mysql \u4e2d\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u7684\u8fc7\u7a0b\u5982\u4e0b\uff1a\u4f7f\u7528\u67e5\u8be2\u8bc6\u522b\u91cd\u590d\u6570\u636e\u5e93\u3002\u4f7f\u7528 drop database \u8bed\u53e5\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u3002\u4f7f\u7528 show databases \u9a8c\u8bc1\u91cd\u590d\u6570\u636e\u5e93\u662f\u5426\u5df2\u5220\u9664\u3002 \u5982\u4f55\u5220\u9664 MySQL \u4e2d\u7684\u91cd\u590d\u6570\u636e\u5e93 MySQL \u4e2d\u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u8bc6\u522b\u91cd\u590d\u6570\u636e\u5e93\uff1a \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bc6\u522b\u91cd\u590d\u7684\u6570\u636e\u5e93\uff1a SELECT COUNT(DISTINCT database_name) FROM information_schema.schemata GROUP BY database_name HAVING COUNT(*) &gt; 1; \u767b\u5f55\u540e\u590d\u5236 \u8be5\u67e5\u8be2\u5c06\u8fd4\u56de\u91cd\u590d\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 \u5220\u9664\u91cd\u590d\u6570\u636e\u5e93\uff1a \u4f7f\u7528 DROP DATABASE \u8bed\u53e5\u5220\u9664\u91cd\u590d\u7684\u6570\u636e\u5e93\uff1a DROP DATABASE &lt;database_name&gt;; \u767b\u5f55\u540e\u590d\u5236 \u66ff\u6362 \u4e3a\u91cd\u590d\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 \u9a8c\u8bc1\u5220\u9664\uff1a \u4f7f\u7528 SHOW DATABASES; \u8bed\u53e5\u9a8c\u8bc1\u91cd\u590d\u6570\u636e\u5e93\u662f\u5426\u5df2\u5220\u9664\uff1a SHOW DATABASES; \u767b\u5f55\u540e\u590d\u5236 \u8f93\u51fa\u4e0d\u5e94\u518d\u5305\u542b\u91cd\u590d\u7684\u6570\u636e\u5e93\u3002 \u5176\u4ed6\u6ce8\u610f\u4e8b\u9879\uff1a \u5728\u5220\u9664\u6570\u636e\u5e93\u4e4b\u524d\uff0c\u8bf7\u5907\u4efd\u6570\u636e\uff0c\u56e0\u4e3a\u8be5\u64cd\u4f5c\u662f\u4e0d\u53ef\u9006\u7684\u3002 \u5982\u679c\u6570\u636e\u5e93\u4e2d\u5305\u542b\u8868\u6216\u5176\u4ed6\u5bf9\u8c61\uff0c\u5728\u5220\u9664\u6570\u636e\u5e93\u4e4b\u524d\u5fc5\u987b\u5148\u5220\u9664\u8fd9\u4e9b\u5bf9\u8c61\u3002 \u4f7f\u7528 -f \u9009\u9879\u5f3a\u5236\u5220\u9664\u6570\u636e\u5e93\uff0c\u5373\u4f7f\u8be5\u6570\u636e\u5e93\u4e0d\u4e3a\u7a7a\u3002 [&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-6515","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6515","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=6515"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6515\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}