{"id":5460,"date":"2024-11-14T09:16:05","date_gmt":"2024-11-14T01:16:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5460\/"},"modified":"2024-11-14T09:16:05","modified_gmt":"2024-11-14T01:16:05","slug":"mysql%e6%80%8e%e4%b9%88%e5%af%bc%e5%87%ba%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5460\/","title":{"rendered":"mysql\u600e\u4e48\u5bfc\u51fa\u5e93"},"content":{"rendered":"<blockquote><p>\n  \u5bfc\u51fa mysql \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u767b\u5f55 mysql \u5e76\u8fde\u63a5\u5230\u9700\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u6307\u5b9a\u6570\u636e\u5e93\u540d\u79f0\u548c\u5bfc\u51fa\u6587\u4ef6\u3002\u53ef\u4f7f\u7528\u9009\u9879\u6307\u5b9a\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u6216\u5305\u542b\u6570\u636e\u5e93\u3001\u8868\u3001\u6570\u636e\u7684\u76f8\u5173\u8bed\u53e5\u3002\u6267\u884c\u5bfc\u51fa\u547d\u4ee4\u3002\u53ef\u6307\u5b9a\u7279\u5b9a\u8868\u8fdb\u884c\u5bfc\u51fa\u3002\u901a\u8fc7\u6dfb\u52a0 &#8211;compress \u9009\u9879\uff0c\u5bfc\u51fa\u4e3a gzip \u538b\u7f29\u6587\u4ef6\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/28\/2024052815032412480.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u5bfc\u51fa\u5e93\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u5bfc\u51fa\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u5bfc\u51fa\u6570\u636e\u5e93<\/strong><\/p>\n<p><strong>\u5bfc\u51fa\u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>1. \u4f7f\u7528\u547d\u4ee4\u884c\u767b\u5f55 MySQL<\/strong><\/p>\n<pre>mysql -u \u7528\u6237\u540d -p \u5bc6\u7801<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u8fde\u63a5\u5230\u9700\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93<\/strong><\/p>\n<pre>use \u6570\u636e\u5e93\u540d\u79f0;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u4f7f\u7528 dump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u57fa\u672c\u8bed\u6cd5\uff1a<\/p>\n<pre>mysqldump [\u9009\u9879] \u6570\u636e\u5e93\u540d\u79f0 &gt; \u5bfc\u51fa\u6587\u4ef6.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5e38\u898b\u9078\u9805\uff1a<\/p>\n<ul>\n<li>-u\uff1a\u6307\u5b9a MySQL \u7528\u6236\u540d<\/li>\n<li>-p\uff1a\u6307\u5b9a MySQL \u5bc6\u78bc<\/li>\n<li>-B\uff1a\u5c07\u5275\u5efa\u6578\u64da\u5eab\u8a9e\u53e5\u5305\u542b\u5728\u5c0e\u51fa\u6587\u4ef6\u4e2d<\/li>\n<li>-T\uff1a\u5c07 CREATE TABLE \u8a9e\u53e5\u5305\u542b\u5728\u5c0e\u51fa\u6587\u4ef6\u4e2d<\/li>\n<li>-R\uff1a\u5c07 INSERT \u6578\u64da\u8a9e\u53e5\u5305\u542b\u5728\u5c0e\u51fa\u6587\u4ef6\u4e2d<\/li>\n<\/ul>\n<p><strong>4. \u6267\u884c\u5bfc\u51fa\u547d\u4ee4<\/strong><\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u5c07\u540d\u4e3a my_database \u7684\u6570\u636e\u5e93\u5bfc\u51fa\u5230\u6587\u4ef6 backup.sql \u4e2d\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 my_database &gt; backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u5bfc\u51fa\u7279\u5b9a\u8868<\/strong><\/p>\n<p>\u5982\u679c\u53ea\u60f3\u5bfc\u51fa\u7279\u5b9a\u8868\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u4e2d\u6307\u5b9a\u8868\u540d\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 my_database \u8868\u540d1 \u8868\u540d2 &gt; backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. \u5bfc\u51fa\u5230 GZIP \u538b\u7f29\u6587\u4ef6<\/strong><\/p>\n<p>\u901a\u8fc7\u5c06 &#8211;compress \u9009\u9879\u6dfb\u52a0\u5230\u547d\u4ee4\u4e2d\uff0c\u53ef\u4ee5\u5c06\u5bfc\u51fa\u7684\u6587\u4ef6\u538b\u7f29\u4e3a GZIP \u683c\u5f0f\uff1a<\/p>\n<pre>mysqldump -u \u7528\u6237\u540d -p \u5bc6\u7801 my_database --compress &gt; backup.sql.gz<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bfc\u51fa\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 mysql \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u767b\u5f55 mysql \u5e76\u8fde\u63a5\u5230\u9700\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u6307\u5b9a\u6570\u636e\u5e93\u540d\u79f0\u548c\u5bfc\u51fa\u6587\u4ef6\u3002\u53ef\u4f7f\u7528\u9009\u9879\u6307\u5b9a\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u6216\u5305\u542b\u6570\u636e\u5e93\u3001\u8868\u3001\u6570\u636e\u7684\u76f8\u5173\u8bed\u53e5\u3002\u6267\u884c\u5bfc\u51fa\u547d\u4ee4\u3002\u53ef\u6307\u5b9a\u7279\u5b9a\u8868\u8fdb\u884c\u5bfc\u51fa\u3002\u901a\u8fc7\u6dfb\u52a0 &#8211;compress \u9009\u9879\uff0c\u5bfc\u51fa\u4e3a gzip \u538b\u7f29\u6587\u4ef6\u3002 MySQL \u5bfc\u51fa\u6570\u636e\u5e93 \u5bfc\u51fa\u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a 1. \u4f7f\u7528\u547d\u4ee4\u884c\u767b\u5f55 MySQL mysql -u \u7528\u6237\u540d -p \u5bc6\u7801 \u767b\u5f55\u540e\u590d\u5236 2. \u8fde\u63a5\u5230\u9700\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93 use \u6570\u636e\u5e93\u540d\u79f0; \u767b\u5f55\u540e\u590d\u5236 3. \u4f7f\u7528 dump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93 \u57fa\u672c\u8bed\u6cd5\uff1a mysqldump [\u9009\u9879] \u6570\u636e\u5e93\u540d\u79f0 &gt; \u5bfc\u51fa\u6587\u4ef6.sql \u767b\u5f55\u540e\u590d\u5236 \u5e38\u898b\u9078\u9805\uff1a -u\uff1a\u6307\u5b9a MySQL \u7528\u6236\u540d -p\uff1a\u6307\u5b9a MySQL \u5bc6\u78bc -B\uff1a\u5c07\u5275\u5efa\u6578\u64da\u5eab\u8a9e\u53e5\u5305\u542b\u5728\u5c0e\u51fa\u6587\u4ef6\u4e2d -T\uff1a\u5c07 CREATE TABLE \u8a9e\u53e5\u5305\u542b\u5728\u5c0e\u51fa\u6587\u4ef6\u4e2d -R\uff1a\u5c07 INSERT \u6578\u64da\u8a9e\u53e5\u5305\u542b\u5728\u5c0e\u51fa\u6587\u4ef6\u4e2d 4. [&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-5460","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5460","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=5460"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5460\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}