{"id":6542,"date":"2024-11-14T12:00:48","date_gmt":"2024-11-14T04:00:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6542\/"},"modified":"2024-11-14T12:00:48","modified_gmt":"2024-11-14T04:00:48","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e5%af%bc%e5%87%ba%e5%a4%9a%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6542\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u51fa\u591a\u8868"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e09\u79cd\u65b9\u6cd5\u5bfc\u51fa mysql \u591a\u8868\uff1a\u4f7f\u7528 mysqldump \u5de5\u5177\u6279\u91cf\u5bfc\u51fa\u6307\u5b9a\u8868\u3002\u4f7f\u7528 phpmyadmin \u754c\u9762\u9009\u62e9\u5e76\u5bfc\u51fa\u591a\u4e2a\u8868\u3002\u901a\u8fc7\u7f16\u5199 sql \u67e5\u8be2\u521b\u5efa\u4e34\u65f6\u8868\u5e76\u5bfc\u51fa\u6570\u636e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520043338110.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u51fa\u591a\u8868\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u51fa\u591a\u8868\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 MySQL \u5bfc\u51fa\u591a\u8868<\/strong><\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528 dump<\/strong><\/p>\n<p>mysqldump \u662f\u4e00\u4e2a\u7528\u4e8e\u5907\u4efd MySQL \u6570\u636e\u5e93\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u4e00\u6b21\u5bfc\u51fa\u591a\u4e2a\u8868\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528 mysqldump \u5bfc\u51fa\u591a\u8868\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d \u8868\u683c1 \u8868\u683c2 ... &gt; \u5bfc\u51fa\u6587\u4ef6.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5bfc\u51fa user \u548c post \u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysqldump -u root -p my_db user post &gt; \u591a\u8868\u5bfc\u51fa.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528 phpMyAdmin<\/strong><\/p>\n<p>phpMyAdmin \u662f\u4e00\u4e2a\u57fa\u4e8e Web \u7684 MySQL \u7ba1\u7406\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u5bfc\u51fa\u9009\u5b9a\u7684\u591a\u4e2a\u8868\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528 phpMyAdmin \u5bfc\u51fa\u591a\u8868\uff1a<\/p>\n<ol>\n<li>\u767b\u5f55 phpMyAdmin\u3002<\/li>\n<li>\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002<\/li>\n<li>\u52fe\u9009\u8981\u5bfc\u51fa\u7684\u8868\u7684\u590d\u9009\u6846\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u5bfc\u51fa\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\u9009\u62e9\u201c\u81ea\u5b9a\u4e49\u201d\u9009\u9879\u3002<\/li>\n<li>\u5728\u201c\u8868\u201d\u90e8\u5206\u4e2d\uff0c\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u8868\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u8f6c\u50a8\u201d\u6309\u94ae\u3002<\/li>\n<\/ol>\n<p>\u5bfc\u51fa\u7684\u6570\u636e\u5c06\u4ee5 SQL \u683c\u5f0f\u4e0b\u8f7d\u5230\u60a8\u7684\u8ba1\u7b97\u673a\u3002<\/p>\n<p><strong>\u65b9\u6cd5 3\uff1a\u4f7f\u7528 SQL \u67e5\u8be2<\/strong><\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 SQL \u67e5\u8be2\u624b\u52a8\u5bfc\u51fa\u591a\u8868\u3002\u8be5\u65b9\u6cd5\u6d89\u53ca\u521b\u5efa\u5305\u542b\u6240\u6709\u8868\u6570\u636e\u7684\u4e34\u65f6\u8868\uff0c\u7136\u540e\u5c06\u5176\u5bfc\u51fa\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u6267\u884c\u6b64\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8868\uff1a<\/li>\n<\/ol>\n<pre>CREATE TEMPORARY TABLE combined_data AS\nSELECT * FROM table1\nUNION\nSELECT * FROM table2;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5bfc\u51fa\u4e34\u65f6\u8868\uff1a<\/li>\n<\/ol>\n<pre>SELECT * FROM combined_data INTO OUTFILE '\u5bfc\u51fa\u6587\u4ef6.csv'\nFIELDS TERMINATED BY ','\nLINES TERMINATED BY '\n';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5bfc\u51fa\u7684\u6570\u636e\u5c06\u4ee5 CSV \u683c\u5f0f\u4e0b\u8f7d\u5230\u60a8\u7684\u8ba1\u7b97\u673a\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u600e\u4e48\u5bfc\u51fa\u591a\u8868\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>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e09\u79cd\u65b9\u6cd5\u5bfc\u51fa mysql \u591a\u8868\uff1a\u4f7f\u7528 mysqldump \u5de5\u5177\u6279\u91cf\u5bfc\u51fa\u6307\u5b9a\u8868\u3002\u4f7f\u7528 phpmyadmin \u754c\u9762\u9009\u62e9\u5e76\u5bfc\u51fa\u591a\u4e2a\u8868\u3002\u901a\u8fc7\u7f16\u5199 sql \u67e5\u8be2\u521b\u5efa\u4e34\u65f6\u8868\u5e76\u5bfc\u51fa\u6570\u636e\u3002 \u5982\u4f55\u4f7f\u7528 MySQL \u5bfc\u51fa\u591a\u8868 \u65b9\u6cd5 1\uff1a\u4f7f\u7528 dump mysqldump \u662f\u4e00\u4e2a\u7528\u4e8e\u5907\u4efd MySQL \u6570\u636e\u5e93\u7684\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u4e00\u6b21\u5bfc\u51fa\u591a\u4e2a\u8868\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528 mysqldump \u5bfc\u51fa\u591a\u8868\uff1a mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d \u8868\u683c1 \u8868\u683c2 &#8230; &gt; \u5bfc\u51fa\u6587\u4ef6.sql \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u5bfc\u51fa user \u548c post \u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a mysqldump -u root -p my_db user post &gt; \u591a\u8868\u5bfc\u51fa.sql \u767b\u5f55\u540e\u590d\u5236 \u65b9\u6cd5 2\uff1a\u4f7f\u7528 phpMyAdmin phpMyAdmin \u662f\u4e00\u4e2a\u57fa\u4e8e Web \u7684 [&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-6542","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6542","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=6542"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6542\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}