{"id":6570,"date":"2024-11-14T10:53:54","date_gmt":"2024-11-14T02:53:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6570\/"},"modified":"2024-11-14T10:53:54","modified_gmt":"2024-11-14T02:53:54","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e6%9f%a5%e8%af%a2%e5%af%bc%e5%87%ba%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6570\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u600e\u4e48\u67e5\u8be2\u5bfc\u51fa\u6570\u636e"},"content":{"rendered":"<blockquote><p>\n  \u901a\u8fc7\u547d\u4ee4\u884c\u5de5\u5177\uff08mysqldump\uff09\u6216 phpmyadmin \u53ef\u4ee5\u5bfc\u51fa mysql \u6570\u636e\u5e93\u6570\u636e\u3002\u67e5\u8be2\u6570\u636e\u65f6\uff0c\u4f7f\u7528 sql \u67e5\u8be2\u8bed\u53e5\u6307\u5b9a\u5217\u540d\u548c\u6761\u4ef6\uff0c\u7ed3\u679c\u53ef\u5bfc\u51fa\u4e3a\u6587\u4ef6\u6216\u5bfc\u5165\u5176\u4ed6\u6570\u636e\u5e93\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520364879703.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u67e5\u8be2\u5bfc\u51fa\u6570\u636e\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u67e5\u8be2\u5bfc\u51fa\u6570\u636e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4ece MySQL \u6570\u636e\u5e93\u67e5\u8be2\u5e76\u5bfc\u51fa\u6570\u636e<\/strong><\/p>\n<p><strong>\u5bfc\u51fa\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p><strong>1. \u4f7f\u7528 dump \u547d\u4ee4\u884c\u5de5\u5177\uff1a<\/strong><\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d \u8868\u540d &gt; \u5bfc\u51fa\u6587\u4ef6.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528 PHPMyAdmin\uff1a<\/strong><\/p>\n<ul>\n<li>\u6253\u5f00 PHPMyAdmin \u5e76\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002<\/li>\n<li>\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u8868\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u5bfc\u51fa\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\u9009\u62e9\u201c\u5e38\u7528\u9009\u9879\u201d\u3002<\/li>\n<li>\u9009\u62e9\u5bfc\u51fa\u683c\u5f0f\uff08\u901a\u5e38\u4e3a SQL\uff09\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u6267\u884c\u201d\u6309\u94ae\u3002<\/li>\n<\/ul>\n<p><strong>\u67e5\u8be2\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 SQL \u67e5\u8be2\u8bed\u53e5\u4ece\u8868\u4e2d\u63d0\u53d6\u7279\u5b9a\u6570\u636e\uff0c\u7136\u540e\u518d\u5bfc\u51fa\u3002<\/p>\n<p><strong>\u67e5\u8be2\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>SELECT \u5217\u540d1, \u5217\u540d2, ...\nFROM \u8868\u540d\nWHERE \u6761\u4ef6<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5bfc\u51fa\u67e5\u8be2\u7ed3\u679c\uff1a<\/strong><\/p>\n<p><strong>1. \u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff1a<\/strong><\/p>\n<pre>mysql -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d -e \"SELECT ... FROM ...\" &gt; \u5bfc\u51fa\u6587\u4ef6.csv<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u5c06\u67e5\u8be2\u7ed3\u679c\u5bfc\u5165\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\uff1a<\/strong><\/p>\n<pre>mysql -u \u7528\u6237\u540d -p \u5bc6\u7801 \u76ee\u6807\u6570\u636e\u5e93 &lt; \u5bfc\u51fa\u6587\u4ef6.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5b9e\u4f8b\uff1a<\/strong><\/p>\n<p>\u5bfc\u51fa\u540d\u4e3a &#8220;my_table&#8221; \u8868\u4e2d\u6240\u6709\u6570\u636e\uff1a<\/p>\n<pre>mysqldump -u root -p my_database my_table &gt; my_table_export.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u67e5\u8be2 &#8220;my_table&#8221; \u8868\u4e2d &#8220;name&#8221; \u5217\u7684\u503c\uff1a<\/p>\n<pre>SELECT name\nFROM my_table<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u67e5\u8be2\u7ed3\u679c\u5bfc\u51fa\u5230 CSV \u6587\u4ef6\uff1a<\/p>\n<pre>mysql -u root -p my_database -e \"SELECT name FROM my_table\" &gt; names.csv<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u600e\u4e48\u67e5\u8be2\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>\u901a\u8fc7\u547d\u4ee4\u884c\u5de5\u5177\uff08mysqldump\uff09\u6216 phpmyadmin \u53ef\u4ee5\u5bfc\u51fa mysql \u6570\u636e\u5e93\u6570\u636e\u3002\u67e5\u8be2\u6570\u636e\u65f6\uff0c\u4f7f\u7528 sql \u67e5\u8be2\u8bed\u53e5\u6307\u5b9a\u5217\u540d\u548c\u6761\u4ef6\uff0c\u7ed3\u679c\u53ef\u5bfc\u51fa\u4e3a\u6587\u4ef6\u6216\u5bfc\u5165\u5176\u4ed6\u6570\u636e\u5e93\u3002 \u5982\u4f55\u4ece MySQL \u6570\u636e\u5e93\u67e5\u8be2\u5e76\u5bfc\u51fa\u6570\u636e \u5bfc\u51fa\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 dump \u547d\u4ee4\u884c\u5de5\u5177\uff1a mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d \u8868\u540d &gt; \u5bfc\u51fa\u6587\u4ef6.sql \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528 PHPMyAdmin\uff1a \u6253\u5f00 PHPMyAdmin \u5e76\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002 \u9009\u62e9\u8981\u5bfc\u51fa\u7684\u8868\u3002 \u70b9\u51fb\u201c\u5bfc\u51fa\u201d\u9009\u9879\u5361\u3002 \u9009\u62e9\u201c\u5e38\u7528\u9009\u9879\u201d\u3002 \u9009\u62e9\u5bfc\u51fa\u683c\u5f0f\uff08\u901a\u5e38\u4e3a SQL\uff09\u3002 \u70b9\u51fb\u201c\u6267\u884c\u201d\u6309\u94ae\u3002 \u67e5\u8be2\u65b9\u6cd5\uff1a \u4f7f\u7528 SQL \u67e5\u8be2\u8bed\u53e5\u4ece\u8868\u4e2d\u63d0\u53d6\u7279\u5b9a\u6570\u636e\uff0c\u7136\u540e\u518d\u5bfc\u51fa\u3002 \u67e5\u8be2\u8bed\u6cd5\uff1a SELECT \u5217\u540d1, \u5217\u540d2, &#8230; FROM \u8868\u540d WHERE \u6761\u4ef6 \u767b\u5f55\u540e\u590d\u5236 \u5bfc\u51fa\u67e5\u8be2\u7ed3\u679c\uff1a 1. \u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff1a mysql [&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-6570","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6570","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=6570"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6570\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}