{"id":6555,"date":"2024-11-14T09:57:07","date_gmt":"2024-11-14T01:57:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6555\/"},"modified":"2024-11-14T09:57:07","modified_gmt":"2024-11-14T01:57:07","slug":"%e6%80%8e%e4%b9%88%e5%b0%86mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%af%bc%e5%87%ba","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6555\/","title":{"rendered":"\u600e\u4e48\u5c06mysql\u6570\u636e\u5e93\u5bfc\u51fa"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5bfc\u51fa mysql \u6570\u636e\u5e93\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u8fde\u63a5\u5230\u6570\u636e\u5e93\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\u5230 sql \u6587\u4ef6\u53ef\u9009\uff1a\u5bfc\u51fa\u7279\u5b9a\u8868\u53ef\u9009\uff1a\u8bbe\u7f6e\u5bfc\u51fa\u9009\u9879\u4f7f\u7528 mysql \u547d\u4ee4\u5bfc\u5165\u5bfc\u51fa\u6587\u4ef6\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520191815858.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u5c06mysql\u6570\u636e\u5e93\u5bfc\u51fa\u63d2\u56fe\" alt=\"\u600e\u4e48\u5c06mysql\u6570\u636e\u5e93\u5bfc\u51fa\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06 MySQL \u6570\u636e\u5e93\u5bfc\u51fa<\/strong><\/p>\n<p>\u6570\u636e\u5e93\u5bfc\u51fa\u662f\u5c06\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u548c\u7ed3\u6784\u590d\u5236\u5230\u5916\u90e8\u6587\u4ef6\u7684\u8fc7\u7a0b\uff0c\u7528\u4e8e\u5907\u4efd\u3001\u8fc1\u79fb\u6216\u5b58\u6863\u76ee\u7684\u3002\u4ee5\u4e0b\u662f\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u8fde\u63a5\u5230\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u4f7f\u7528\u547d\u4ee4\u884c\u6216\u7b2c\u4e09\u65b9\u5de5\u5177\uff08\u5982 MySQL Workbench\uff09\u8fde\u63a5\u5230\u76ee\u6807\u6570\u636e\u5e93\u3002<\/p>\n<pre>mysql -u username -p password<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u4f7f\u7528 USE \u547d\u4ee4\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\uff1a<\/p>\n<pre>USE database_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u5bfc\u51fa\u6570\u636e\u5e93\u5230 SQL \u6587\u4ef6<\/strong><\/p>\n<p>\u4f7f\u7528 dump \u547d\u4ee4\u5c06\u6570\u636e\u5e93\u5bfc\u51fa\u5230 SQL \u6587\u4ef6\u3002\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6574\u4e2a\u6570\u636e\u5e93\u5bfc\u51fa\u5230\u540d\u4e3a database_backup.sql \u7684\u6587\u4ef6\uff1a<\/p>\n<pre>mysqldump --user=username --password=password database_name &gt; database_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u5bfc\u51fa\u7279\u5b9a\u8868\uff08\u53ef\u9009\uff09<\/strong><\/p>\n<p>\u8981\u5bfc\u51fa\u7279\u5b9a\u8868\uff0c\u8bf7\u5728 mysqldump \u547d\u4ee4\u4e2d\u6307\u5b9a\u8868\u540d\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>mysqldump --user=username --password=password database_name table_name &gt; table_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u8bbe\u7f6e\u5bfc\u51fa\u9009\u9879\uff08\u53ef\u9009\uff09<\/strong><\/p>\n<p>mysqldump \u547d\u4ee4\u63d0\u4f9b\u5404\u79cd\u9009\u9879\u6765\u81ea\u5b9a\u4e49\u5bfc\u51fa\u8fc7\u7a0b\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>&#8211;lock-tables: \u5728\u5bfc\u51fa\u671f\u95f4\u9501\u5b9a\u8868\uff0c\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027\u3002<\/li>\n<li>&#8211;single-transaction: \u4ee5\u5355\u4e2a\u4e8b\u52a1\u5bfc\u51fa\u8868\uff0c\u786e\u4fdd\u539f\u5b50\u6027\u3002<\/li>\n<li>&#8211;skip-extended-insert: \u8df3\u8fc7\u5bf9 INSERT \u8bed\u53e5\u7684\u6269\u5c55\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<p><strong>6. \u5bfc\u5165\u5bfc\u51fa\u6587\u4ef6<\/strong><\/p>\n<p>\u8981\u5bfc\u5165\u5bfc\u51fa\u7684\u6570\u636e\uff0c\u8bf7\u4f7f\u7528 mysql \u547d\u4ee4\u5c06 SQL \u6587\u4ef6\u52a0\u8f7d\u5230\u76ee\u6807\u6570\u636e\u5e93\uff1a<\/p>\n<pre>mysql -u username -p password &lt; database_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5c06\u6570\u636e\u5e93\u5bfc\u51fa\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>\u8981\u5bfc\u51fa mysql \u6570\u636e\u5e93\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u8fde\u63a5\u5230\u6570\u636e\u5e93\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u6570\u636e\u5e93\u5230 sql \u6587\u4ef6\u53ef\u9009\uff1a\u5bfc\u51fa\u7279\u5b9a\u8868\u53ef\u9009\uff1a\u8bbe\u7f6e\u5bfc\u51fa\u9009\u9879\u4f7f\u7528 mysql \u547d\u4ee4\u5bfc\u5165\u5bfc\u51fa\u6587\u4ef6 \u5982\u4f55\u5c06 MySQL \u6570\u636e\u5e93\u5bfc\u51fa \u6570\u636e\u5e93\u5bfc\u51fa\u662f\u5c06\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u548c\u7ed3\u6784\u590d\u5236\u5230\u5916\u90e8\u6587\u4ef6\u7684\u8fc7\u7a0b\uff0c\u7528\u4e8e\u5907\u4efd\u3001\u8fc1\u79fb\u6216\u5b58\u6863\u76ee\u7684\u3002\u4ee5\u4e0b\u662f\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a 1. \u8fde\u63a5\u5230\u6570\u636e\u5e93 \u4f7f\u7528\u547d\u4ee4\u884c\u6216\u7b2c\u4e09\u65b9\u5de5\u5177\uff08\u5982 MySQL Workbench\uff09\u8fde\u63a5\u5230\u76ee\u6807\u6570\u636e\u5e93\u3002 mysql -u username -p password \u767b\u5f55\u540e\u590d\u5236 2. \u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93 \u4f7f\u7528 USE \u547d\u4ee4\u9009\u62e9\u8981\u5bfc\u51fa\u7684\u6570\u636e\u5e93\uff1a USE database_name; \u767b\u5f55\u540e\u590d\u5236 3. \u5bfc\u51fa\u6570\u636e\u5e93\u5230 SQL \u6587\u4ef6 \u4f7f\u7528 dump \u547d\u4ee4\u5c06\u6570\u636e\u5e93\u5bfc\u51fa\u5230 SQL \u6587\u4ef6\u3002\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6574\u4e2a\u6570\u636e\u5e93\u5bfc\u51fa\u5230\u540d\u4e3a database_backup.sql \u7684\u6587\u4ef6\uff1a mysqldump &#8211;user=username &#8211;password=password database_name &gt; database_backup.sql \u767b\u5f55\u540e\u590d\u5236 4. \u5bfc\u51fa\u7279\u5b9a\u8868\uff08\u53ef\u9009\uff09 \u8981\u5bfc\u51fa\u7279\u5b9a\u8868\uff0c\u8bf7\u5728 [&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-6555","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6555","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=6555"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6555\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}