{"id":6564,"date":"2024-11-14T12:46:24","date_gmt":"2024-11-14T04:46:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6564\/"},"modified":"2024-11-14T12:46:24","modified_gmt":"2024-11-14T04:46:24","slug":"mysql%e6%80%8e%e4%b9%88%e5%af%bc%e5%87%ba%e6%9f%a5%e8%af%a2%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6564\/","title":{"rendered":"mysql\u600e\u4e48\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93"},"content":{"rendered":"<blockquote><p>\n  \u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528 mysqldump \u547d\u4ee4\u884c\u5de5\u5177\u3002\u4f7f\u7528 select into outfile \u8bed\u53e5\u76f4\u63a5\u8f93\u51fa\u5230\u6587\u672c\u6587\u4ef6\u3002\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\uff0c\u5982 mysql workbench\u3001heidisql\u3001navicat premium \u7b49\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520311448508.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u4e2d\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\u7684\u65b9\u6cd5<\/strong><\/p>\n<p><strong>1. \u4f7f\u7528 dump \u547d\u4ee4<\/strong><\/p>\n<p>mysqldump \u662f MySQL \u63d0\u4f9b\u7684\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u51fa\u67e5\u8be2\u7ed3\u679c\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d -e \"\u67e5\u8be2\u8bed\u53e5\" &gt; \u8f93\u51fa\u6587\u4ef6\u540d.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5bfc\u51fa\u540d\u4e3a users \u8868\u4e2d\u6240\u6709\u7528\u6237\u7684\u67e5\u8be2\u7ed3\u679c\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysqldump -u root -p my_database -e \"SELECT * FROM users;\" &gt; users.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528 SELECT INTO OUTFILE \u8bed\u53e5<\/strong><\/p>\n<p>SELECT INTO OUTFILE \u8bed\u53e5\u5141\u8bb8\u5c06\u67e5\u8be2\u7ed3\u679c\u76f4\u63a5\u8f93\u51fa\u5230\u6587\u672c\u6587\u4ef6\u4e2d\u3002\u8be5\u8bed\u53e5\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SELECT ... INTO OUTFILE '\u8f93\u51fa\u6587\u4ef6\u540d.txt'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5c06\u4e0a\u4e00\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u5bfc\u51fa\u5230\u540d\u4e3a users.txt \u7684\u6587\u672c\u6587\u4ef6\u4e2d\uff0c\u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>SELECT * FROM users INTO OUTFILE 'users.txt';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177<\/strong><\/p>\n<p>\u9664\u4e86 MySQL \u81ea\u5e26\u7684\u5de5\u5177\u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u7b2c\u4e09\u65b9\u5de5\u5177\u53ef\u4ee5\u7528\u4e8e\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u3002\u8fd9\u4e9b\u5de5\u5177\u901a\u5e38\u63d0\u4f9b\u66f4\u76f4\u89c2\u7684\u7528\u6237\u754c\u9762\u548c\u66f4\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>MySQL Workbench<\/li>\n<li>HeidiSQL<\/li>\n<li>Navicat Premium<\/li>\n<\/ul>\n<p>\u8bf7\u6839\u636e\u60a8\u7684\u5177\u4f53\u9700\u6c42\u548c\u504f\u597d\u9009\u62e9\u5408\u9002\u7684\u5bfc\u51fa\u65b9\u6cd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\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>\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528 mysqldump \u547d\u4ee4\u884c\u5de5\u5177\u3002\u4f7f\u7528 select into outfile \u8bed\u53e5\u76f4\u63a5\u8f93\u51fa\u5230\u6587\u672c\u6587\u4ef6\u3002\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\uff0c\u5982 mysql workbench\u3001heidisql\u3001navicat premium \u7b49\u3002 MySQL \u4e2d\u5bfc\u51fa\u67e5\u8be2\u6570\u636e\u5e93\u7684\u65b9\u6cd5 1. \u4f7f\u7528 dump \u547d\u4ee4 mysqldump \u662f MySQL \u63d0\u4f9b\u7684\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u51fa\u67e5\u8be2\u7ed3\u679c\uff1a mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 \u6570\u636e\u5e93\u540d -e &#8220;\u67e5\u8be2\u8bed\u53e5&#8221; &gt; \u8f93\u51fa\u6587\u4ef6\u540d.sql \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u5bfc\u51fa\u540d\u4e3a users \u8868\u4e2d\u6240\u6709\u7528\u6237\u7684\u67e5\u8be2\u7ed3\u679c\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a mysqldump -u root -p my_database -e &#8220;SELECT * FROM users;&#8221; &gt; users.sql \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528 SELECT INTO OUTFILE \u8bed\u53e5 SELECT [&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-6564","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6564","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=6564"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6564\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}