{"id":6562,"date":"2024-11-14T08:48:59","date_gmt":"2024-11-14T00:48:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6562\/"},"modified":"2024-11-14T08:48:59","modified_gmt":"2024-11-14T00:48:59","slug":"%e6%80%8e%e4%b9%88%e6%8a%8a%e6%95%b0%e6%8d%ae%e5%ba%93%e5%af%bc%e5%87%bamysql","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6562\/","title":{"rendered":"\u600e\u4e48\u628a\u6570\u636e\u5e93\u5bfc\u51famysql"},"content":{"rendered":"<blockquote><p>\n  mysql \u6570\u636e\u5e93\u5bfc\u51fa\u6b65\u9aa4\u5982\u4e0b\uff1a\u767b\u5f55 mysql \u670d\u52a1\u5668\u5e76\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u4fdd\u5b58\u5230\u6587\u4ef6\u6216\u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002\u5bfc\u51fa\u5b8c\u6210\uff0c\u9000\u51fa mysql\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520280089215.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u628a\u6570\u636e\u5e93\u5bfc\u51famysql\u63d2\u56fe\" alt=\"\u600e\u4e48\u628a\u6570\u636e\u5e93\u5bfc\u51famysql\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06 MySQL \u6570\u636e\u5e93\u5bfc\u51fa<\/strong><\/p>\n<p>\u5bfc\u51fa\u6570\u636e\u5e93\u662f\u521b\u5efa\u5907\u4efd\u6216\u5c06\u5176\u8f6c\u79fb\u5230\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u65f6\u7684\u5fc5\u8981\u6b65\u9aa4\u3002\u4ee5\u4e0b\u662f\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u767b\u5f55 MySQL<\/strong><\/p>\n<p>\u4f7f\u7528 root \u7528\u6237\u767b\u5f55 MySQL \u670d\u52a1\u5668\u3002<\/p>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 2\uff1a\u9009\u62e9\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002<\/p>\n<pre>USE database_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 3\uff1a\u5bfc\u51fa\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u4f7f\u7528 dump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\u3002\u60a8\u53ef\u4ee5\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230\u6587\u4ef6\u6216\u76f4\u63a5\u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002<\/p>\n<p><strong>\u4fdd\u5b58\u5230\u6587\u4ef6\uff1a<\/strong><\/p>\n<pre>mysqldump database_name &gt; database_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff1a<\/strong><\/p>\n<pre>mysqldump database_name | mysql -h new_host -u new_user -p new_password new_database<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u53c2\u6570\u89e3\u91ca\uff1a<\/strong><\/p>\n<ul>\n<li>database_name\uff1a\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002<\/li>\n<li>database_backup.sql\uff1a\u4fdd\u5b58\u5bfc\u51fa\u7684 SQL \u6587\u4ef6\u7684\u8def\u5f84\u548c\u540d\u79f0\u3002<\/li>\n<li>new_host\uff1a\u65b0\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u5730\u5740\u3002<\/li>\n<li>new_user\uff1a\u65b0\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u7528\u6237\u540d\u3002<\/li>\n<li>new_password\uff1a\u65b0\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u5bc6\u7801\u3002<\/li>\n<li>new_database\uff1a\u65b0\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u9009\u9879\uff1a<\/strong><\/p>\n<p>\u8981\u81ea\u5b9a\u4e49\u5bfc\u51fa\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u9009\u9879\uff1a<\/p>\n<ul>\n<li>&#8211;all-databases\uff1a\u5bfc\u51fa\u6240\u6709\u6570\u636e\u5e93\u3002<\/li>\n<li>&#8211;tables\uff1a\u4ec5\u5bfc\u51fa\u6307\u5b9a\u8868\u3002<\/li>\n<li>&#8211;skip-extended-insert\uff1a\u4f7f\u7528\u66f4\u7d27\u51d1\u3001\u66f4\u5feb\u7684\u63d2\u5165\u8bed\u6cd5\u3002<\/li>\n<li>&#8211;compact\uff1a\u751f\u6210\u66f4\u5c0f\u7684\u8f6c\u50a8\u6587\u4ef6\u3002<\/li>\n<li>&#8211;no-create-db\uff1a\u4e0d\u521b\u5efa\u76ee\u6807\u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 4\uff1a\u9000\u51fa MySQL<\/strong><\/p>\n<p>\u5bfc\u51fa\u5b8c\u6210\u540e\uff0c\u9000\u51fa MySQL\u3002<\/p>\n<pre>exit;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u628a\u6570\u636e\u5e93\u5bfc\u51fa\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 \u6570\u636e\u5e93\u5bfc\u51fa\u6b65\u9aa4\u5982\u4e0b\uff1a\u767b\u5f55 mysql \u670d\u52a1\u5668\u5e76\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u4fdd\u5b58\u5230\u6587\u4ef6\u6216\u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002\u5bfc\u51fa\u5b8c\u6210\uff0c\u9000\u51fa mysql\u3002 \u5982\u4f55\u5c06 MySQL \u6570\u636e\u5e93\u5bfc\u51fa \u5bfc\u51fa\u6570\u636e\u5e93\u662f\u521b\u5efa\u5907\u4efd\u6216\u5c06\u5176\u8f6c\u79fb\u5230\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u65f6\u7684\u5fc5\u8981\u6b65\u9aa4\u3002\u4ee5\u4e0b\u662f\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a \u6b65\u9aa4 1\uff1a\u767b\u5f55 MySQL \u4f7f\u7528 root \u7528\u6237\u767b\u5f55 MySQL \u670d\u52a1\u5668\u3002 mysql -u root -p \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 2\uff1a\u9009\u62e9\u6570\u636e\u5e93 \u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002 USE database_name; \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 3\uff1a\u5bfc\u51fa\u6570\u636e\u5e93 \u4f7f\u7528 dump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\u3002\u60a8\u53ef\u4ee5\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230\u6587\u4ef6\u6216\u76f4\u63a5\u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002 \u4fdd\u5b58\u5230\u6587\u4ef6\uff1a mysqldump database_name &gt; database_backup.sql \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u670d\u52a1\u5668\uff1a mysqldump database_name | mysql -h new_host -u new_user -p new_password new_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-6562","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6562","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=6562"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6562\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}