{"id":6453,"date":"2024-11-14T10:27:20","date_gmt":"2024-11-14T02:27:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6453\/"},"modified":"2024-11-14T10:27:20","modified_gmt":"2024-11-14T02:27:20","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e5%af%bc%e5%85%a5%e6%95%b0%e6%8d%ae%e5%ba%93%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6453\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 mysql \u6570\u636e\u5e93\uff1f\u8fde\u63a5 mysql \u670d\u52a1\u5668\u3002\u521b\u5efa\u8981\u5bfc\u5165\u6587\u4ef6\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528\u547d\u4ee4\uff1amysql database_name <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080507464243861.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 MySQL \u6570\u636e\u5e93<\/strong><\/p>\n<p>\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 MySQL \u6570\u636e\u5e93\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u7528\u4e8e\u5907\u4efd\u548c\u6062\u590d\u6570\u636e\uff0c\u6216\u8005\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u6570\u636e\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5de5\u5177\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 MySQL \u6570\u636e\u5e93\u3002<\/p>\n<p><strong>1. \u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a<\/p>\n<pre>mysql -u username -p password<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li> <strong>username<\/strong> \u662f\u6570\u636e\u5e93\u7528\u6237\u540d<\/li>\n<li> <strong>password<\/strong> \u662f\u6570\u636e\u5e93\u5bc6\u7801<\/li>\n<\/ul>\n<p><strong>2. \u521b\u5efa\u8981\u5bfc\u5165\u7684\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u5728\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\u4e4b\u524d\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u8981\u5bfc\u5165\u6587\u4ef6\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\uff1a<\/p>\n<pre>CREATE DATABASE database_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d <strong>database_name<\/strong> \u662f\u8981\u521b\u5efa\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002<\/p>\n<p><strong>3. \u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\uff1a<\/p>\n<pre>mysql database_name &lt; database_file_name<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li> <strong>database_name<\/strong> \u662f\u8981\u5bfc\u5165\u6587\u4ef6\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0<\/li>\n<li> <strong>database_file_name<\/strong> \u662f\u8981\u5bfc\u5165\u7684\u6570\u636e\u5e93\u6587\u4ef6\u7684\u8def\u5f84<\/li>\n<\/ul>\n<p><strong>4. \u9a8c\u8bc1\u5bfc\u5165<\/strong><\/p>\n<p>\u5bfc\u5165\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\uff1a<\/p>\n<pre>USE database_name;\nSHOW TABLES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u663e\u793a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\uff0c\u786e\u8ba4\u5bfc\u5165\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5c06\u540d\u4e3a <strong>my_database.sql<\/strong> \u7684\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165\u5230\u540d\u4e3a <strong>my_imported_database<\/strong> \u7684\u6570\u636e\u5e93\u7684\u793a\u4f8b\uff1a<\/p>\n<pre># \u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\nmysql -u root -p\n\n# \u521b\u5efa\u8981\u5bfc\u5165\u7684\u6570\u636e\u5e93\nCREATE DATABASE my_imported_database;\n\n# \u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\nmysql my_imported_database &lt; my_database.sql\n\n# \u9a8c\u8bc1\u5bfc\u5165\nUSE my_imported_database;\nSHOW TABLES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236\n<\/p><\/blockquote>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\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>\u5982\u4f55\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 mysql \u6570\u636e\u5e93\uff1f\u8fde\u63a5 mysql \u670d\u52a1\u5668\u3002\u521b\u5efa\u8981\u5bfc\u5165\u6587\u4ef6\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528\u547d\u4ee4\uff1amysql database_name \u5982\u4f55\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 MySQL \u6570\u636e\u5e93 \u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 MySQL \u6570\u636e\u5e93\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u7528\u4e8e\u5907\u4efd\u548c\u6062\u590d\u6570\u636e\uff0c\u6216\u8005\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u6570\u636e\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5de5\u5177\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u5bfc\u5165 MySQL \u6570\u636e\u5e93\u3002 1. \u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668 \u9996\u5148\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a mysql -u username -p password \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a username \u662f\u6570\u636e\u5e93\u7528\u6237\u540d password \u662f\u6570\u636e\u5e93\u5bc6\u7801 2. \u521b\u5efa\u8981\u5bfc\u5165\u7684\u6570\u636e\u5e93 \u5728\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\u4e4b\u524d\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u8981\u5bfc\u5165\u6587\u4ef6\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\uff1a CREATE DATABASE database_name; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d database_name \u662f\u8981\u521b\u5efa\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 3. \u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u5165\u6570\u636e\u5e93\u6587\u4ef6\uff1a mysql database_name &lt; database_file_name \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a database_name \u662f\u8981\u5bfc\u5165\u6587\u4ef6\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0 [&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-6453","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6453","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=6453"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6453\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}