{"id":6574,"date":"2024-11-14T12:49:58","date_gmt":"2024-11-14T04:49:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6574\/"},"modified":"2024-11-14T12:49:58","modified_gmt":"2024-11-14T04:49:58","slug":"%e6%80%8e%e4%b9%88%e5%9c%a8mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%af%bc%e5%87%ba%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6574\/","title":{"rendered":"\u600e\u4e48\u5728mysql\u6570\u636e\u5e93\u5bfc\u51fa\u6570\u636e"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u5bfc\u51fa mysql \u6570\u636e\u5e93\u6570\u636e\uff1f\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\u6216\u6307\u5b9a\u8868\uff1b\u6839\u636e\u9700\u8981\u6307\u5b9a\u5bfc\u51fa\u9009\u9879\uff0c\u5982\u5b57\u7b26\u96c6\u548c\u8868\u9501\u5b9a\uff1b\u4f7f\u7528 mysql \u547d\u4ee4\u5bfc\u5165\u5bfc\u51fa\u6587\u4ef6\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520400984530.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u5728mysql\u6570\u636e\u5e93\u5bfc\u51fa\u6570\u636e\u63d2\u56fe\" alt=\"\u600e\u4e48\u5728mysql\u6570\u636e\u5e93\u5bfc\u51fa\u6570\u636e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u6570\u636e<\/strong><\/p>\n<p>\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u6570\u636e\u53ef\u4ee5\u7528\u4e8e\u5907\u4efd\u3001\u8fd8\u539f\u6216\u6570\u636e\u8fc1\u79fb\u3002\u4ee5\u4e0b\u662f\u5bfc\u51fa\u6570\u636e\u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 dump \u547d\u4ee4<\/strong><\/p>\n<p>mysqldump \u662f MySQL \u63d0\u4f9b\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u6570\u636e\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d &gt; \u5bfc\u51fa\u6587\u4ef6\u540d.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>-u \u7528\u6237\u540d\uff1a\u6570\u636e\u5e93\u7528\u6237\u540d<\/li>\n<li>-p \u5bc6\u7801\uff1a\u6570\u636e\u5e93\u5bc6\u7801<\/li>\n<li>\u6570\u636e\u5e93\u540d\uff1a\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u540d<\/li>\n<li>\u5bfc\u51fa\u6587\u4ef6\u540d.sql\uff1a\u5bfc\u51fa\u6587\u4ef6\u7684\u540d\u79f0<\/li>\n<\/ul>\n<p><strong>2. \u6307\u5b9a\u8981\u5bfc\u51fa\u7684\u8868<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u53ea\u60f3\u5bfc\u51fa\u7279\u5b9a\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528 -t \u8868\u540d \u9009\u9879\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d -t \u8868\u540d1 \u8868\u540d2 &gt; \u5bfc\u51fa\u6587\u4ef6\u540d.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u5bfc\u51fa\u9009\u9879<\/strong><\/p>\n<p>mysqldump \u63d0\u4f9b\u4e86\u591a\u79cd\u9009\u9879\u6765\u63a7\u5236\u5bfc\u51fa\u7684\u683c\u5f0f\u548c\u5185\u5bb9\u3002\u4ee5\u4e0b\u662f\u5e38\u7528\u7684\u9009\u9879\uff1a<\/p>\n<ul>\n<li>&#8211;default-character-set=utf8\uff1a\u6307\u5b9a\u9ed8\u8ba4\u5b57\u7b26\u96c6\u4e3a UTF-8<\/li>\n<li>&#8211;create-options\uff1a\u5305\u542b CREATE TABLE \u8bed\u53e5\u4e2d\u7684\u5176\u4ed6\u9009\u9879<\/li>\n<li>&#8211;extended-insert\uff1a\u4f7f\u7528 INSERT \u8bed\u53e5\u7684\u6269\u5c55\u683c\u5f0f<\/li>\n<li>&#8211;lock-tables\uff1a\u5728\u5bfc\u51fa\u8fc7\u7a0b\u4e2d\u9501\u5b9a\u8868<\/li>\n<\/ul>\n<p><strong>4. \u5bfc\u5165\u5bfc\u51fa\u6587\u4ef6<\/strong><\/p>\n<p>\u8981\u5bfc\u5165\u5bfc\u51fa\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysql -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d &lt; \u5bfc\u51fa\u6587\u4ef6\u540d.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5728\u6570\u636e\u5e93\u5bfc\u51fa\u6570\u636e\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\u5bfc\u51fa mysql \u6570\u636e\u5e93\u6570\u636e\uff1f\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\u6216\u6307\u5b9a\u8868\uff1b\u6839\u636e\u9700\u8981\u6307\u5b9a\u5bfc\u51fa\u9009\u9879\uff0c\u5982\u5b57\u7b26\u96c6\u548c\u8868\u9501\u5b9a\uff1b\u4f7f\u7528 mysql \u547d\u4ee4\u5bfc\u5165\u5bfc\u51fa\u6587\u4ef6\u3002 \u5982\u4f55\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u6570\u636e \u5bfc\u51fa MySQL \u6570\u636e\u5e93\u6570\u636e\u53ef\u4ee5\u7528\u4e8e\u5907\u4efd\u3001\u8fd8\u539f\u6216\u6570\u636e\u8fc1\u79fb\u3002\u4ee5\u4e0b\u662f\u5bfc\u51fa\u6570\u636e\u7684\u6b65\u9aa4\uff1a 1. \u4f7f\u7528 dump \u547d\u4ee4 mysqldump \u662f MySQL \u63d0\u4f9b\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u6570\u636e\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\uff1a mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d &gt; \u5bfc\u51fa\u6587\u4ef6\u540d.sql \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a -u \u7528\u6237\u540d\uff1a\u6570\u636e\u5e93\u7528\u6237\u540d -p \u5bc6\u7801\uff1a\u6570\u636e\u5e93\u5bc6\u7801 \u6570\u636e\u5e93\u540d\uff1a\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u540d \u5bfc\u51fa\u6587\u4ef6\u540d.sql\uff1a\u5bfc\u51fa\u6587\u4ef6\u7684\u540d\u79f0 2. \u6307\u5b9a\u8981\u5bfc\u51fa\u7684\u8868 \u5982\u679c\u4f60\u53ea\u60f3\u5bfc\u51fa\u7279\u5b9a\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528 -t \u8868\u540d \u9009\u9879\uff1a mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d -t \u8868\u540d1 \u8868\u540d2 &gt; \u5bfc\u51fa\u6587\u4ef6\u540d.sql \u767b\u5f55\u540e\u590d\u5236 [&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-6574","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6574","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=6574"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6574\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}