{"id":5232,"date":"2024-11-14T12:40:45","date_gmt":"2024-11-14T04:40:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5232\/"},"modified":"2024-11-14T12:40:45","modified_gmt":"2024-11-14T04:40:45","slug":"mysql%e7%99%bb%e5%bd%95%e5%90%8e%e6%80%8e%e4%b9%88%e5%88%87%e6%8d%a2%e7%94%a8%e6%88%b7","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5232\/","title":{"rendered":"mysql\u767b\u5f55\u540e\u600e\u4e48\u5207\u6362\u7528\u6237"},"content":{"rendered":"<blockquote><p>\n  \u5728 mysql \u4e2d\u5207\u6362\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u8fde\u63a5 mysql \u670d\u52a1\u5668\u521b\u5efa\u6216\u9009\u62e9\u6570\u636e\u5e93\u4f7f\u7528 use \u8bed\u53e5\u5207\u6362\u5230\u65b0\u7528\u6237\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052617071054235.jpg\" class=\"aligncenter\" title=\"mysql\u767b\u5f55\u540e\u600e\u4e48\u5207\u6362\u7528\u6237\u63d2\u56fe\" alt=\"mysql\u767b\u5f55\u540e\u600e\u4e48\u5207\u6362\u7528\u6237\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u5207\u6362\u7528\u6237<\/strong><\/p>\n<p><strong>\u5982\u4f55\u5207\u6362 MySQL \u7528\u6237\uff1f<\/strong><\/p>\n<p>\u5728 MySQL \u73af\u5883\u4e2d\u5207\u6362\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 USE \u8bed\u53e5\uff0c\u540e\u8ddf\u8981\u5207\u6362\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u8fde\u63a5 MySQL \u670d\u52a1\u5668\uff1a<\/strong>\u4f7f\u7528  \u547d\u4ee4\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u3002\u4f8b\u5982\uff1amysql -u username -p\u3002<\/li>\n<li> <strong>\u521b\u5efa\u6216\u9009\u62e9\u6570\u636e\u5e93\uff1a<\/strong>\u4f7f\u7528 CREATE DATABASE \u8bed\u53e5\u521b\u5efa\u65b0\u6570\u636e\u5e93\u6216\u4f7f\u7528 USE \u8bed\u53e5\u9009\u62e9\u73b0\u6709\u6570\u636e\u5e93\u3002\u4f8b\u5982\uff1aCREATE DATABASE new_database \u6216 USE existing_database\u3002<\/li>\n<li> <strong>\u5207\u6362\u7528\u6237\uff1a<\/strong>\u4f7f\u7528 USE \u8bed\u53e5\u5207\u6362\u5230\u65b0\u7528\u6237\u3002\u4f8b\u5982\uff1aUSE new_user_database\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u60a8\u5df2\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff0c\u5e76\u4e14\u8981\u5207\u6362\u5230\u540d\u4e3a new_user \u7684\u7528\u6237\uff0c\u8be5\u7528\u6237\u62e5\u6709\u540d\u4e3a new_user_database \u7684\u6570\u636e\u5e93\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5c06\u6267\u884c\u6b64\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u521b\u5efa new_user_database \u6570\u636e\u5e93\uff1aCREATE DATABASE new_user_database;<\/li>\n<li>\u5207\u6362\u5230\u8be5\u6570\u636e\u5e93\uff1aUSE new_user_database;<\/li>\n<li>\u5207\u6362\u5230 new_user \u7528\u6237\uff1aUSE new_user@localhost;<\/li>\n<\/ol>\n<p>\u73b0\u5728\uff0c\u60a8\u5df2\u5207\u6362\u5230 new_user \u7528\u6237\uff0c\u5e76\u5728 new_user_database \u6570\u636e\u5e93\u4e2d\u5de5\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u767b\u5f55\u540e\u600e\u4e48\u5207\u6362\u7528\u6237\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>\u5728 mysql \u4e2d\u5207\u6362\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u8fde\u63a5 mysql \u670d\u52a1\u5668\u521b\u5efa\u6216\u9009\u62e9\u6570\u636e\u5e93\u4f7f\u7528 use \u8bed\u53e5\u5207\u6362\u5230\u65b0\u7528\u6237 MySQL \u5207\u6362\u7528\u6237 \u5982\u4f55\u5207\u6362 MySQL \u7528\u6237\uff1f \u5728 MySQL \u73af\u5883\u4e2d\u5207\u6362\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 USE \u8bed\u53e5\uff0c\u540e\u8ddf\u8981\u5207\u6362\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a \u8fde\u63a5 MySQL \u670d\u52a1\u5668\uff1a\u4f7f\u7528 \u547d\u4ee4\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u3002\u4f8b\u5982\uff1amysql -u username -p\u3002 \u521b\u5efa\u6216\u9009\u62e9\u6570\u636e\u5e93\uff1a\u4f7f\u7528 CREATE DATABASE \u8bed\u53e5\u521b\u5efa\u65b0\u6570\u636e\u5e93\u6216\u4f7f\u7528 USE \u8bed\u53e5\u9009\u62e9\u73b0\u6709\u6570\u636e\u5e93\u3002\u4f8b\u5982\uff1aCREATE DATABASE new_database \u6216 USE existing_database\u3002 \u5207\u6362\u7528\u6237\uff1a\u4f7f\u7528 USE \u8bed\u53e5\u5207\u6362\u5230\u65b0\u7528\u6237\u3002\u4f8b\u5982\uff1aUSE new_user_database\u3002 \u793a\u4f8b\uff1a \u5047\u8bbe\u60a8\u5df2\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff0c\u5e76\u4e14\u8981\u5207\u6362\u5230\u540d\u4e3a new_user \u7684\u7528\u6237\uff0c\u8be5\u7528\u6237\u62e5\u6709\u540d\u4e3a new_user_database \u7684\u6570\u636e\u5e93\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5c06\u6267\u884c\u6b64\u64cd\u4f5c\uff1a \u521b\u5efa new_user_database \u6570\u636e\u5e93\uff1aCREATE DATABASE new_user_database; [&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-5232","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5232","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=5232"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5232\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}