{"id":117,"date":"2006-10-14T19:30:00","date_gmt":"2006-10-14T11:30:00","guid":{"rendered":"http:\/\/elon.852128.com\/blog\/?p=117"},"modified":"2006-10-14T19:30:00","modified_gmt":"2006-10-14T11:30:00","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%a4%87%e4%bb%bdmysqldump%e5%8f%82%e6%95%b0%e9%80%89%e9%a1%b9","status":"publish","type":"post","link":"https:\/\/elon.852128.com\/blog\/2006\/10\/14\/mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%a4%87%e4%bb%bdmysqldump%e5%8f%82%e6%95%b0%e9%80%89%e9%a1%b9\/","title":{"rendered":"MySql\u6570\u636e\u5e93\u5907\u4efdmysqldump\u53c2\u6570\u9009\u9879"},"content":{"rendered":"<p>\u5b9e\u7528\u7a0b\u5e8f\uff0c\u4e3a\u5907\u4efd\u6216\u4e3a\u628a\u6570\u636e\u8f6c\u79fb\u5230\u53e6\u5916\u7684SQL\u670d\u52a1\u5668\u4e0a\u503e\u5012\u4e00\u4e2a\u6570\u636e\u5e93\u6216\u8bb8\u591a\u6570\u636e\u5e93\u3002\u503e\u5012\u5c06\u5305\u542b\u00a0\u521b\u5efa\u8868\u6216\u5145\u5b9e\u8868\u7684SQL\u8bed\u53e5\u3002\u00a0<\/p>\n<p>shell&amp;gt;\u00a0mysqldump\u00a0[OPTIONS]\u00a0database\u00a0[tables]\u00a0<\/p>\n<p>\u5982\u679c\u4f60\u4e0d\u7ed9\u5b9a\u4efb\u4f55\u8868\uff0c\u6574\u4e2a\u6570\u636e\u5e93\u5c06\u88ab\u503e\u5012\u3002\u00a0<\/p>\n<p>\u901a\u8fc7\u6267\u884cmysqldump\u00a0&#8211;help\uff0c\u4f60\u80fd\u5f97\u5230\u4f60mysqldump\u7684\u7248\u672c\u652f\u6301\u7684\u9009\u9879\u8868\u3002\u00a0<\/p>\n<p>\u6ce8\u610f\uff0c\u5982\u679c\u4f60\u8fd0\u884cmysqldump\u6ca1\u6709&#8211;quick\u6216&#8211;opt\u9009\u9879\uff0cmysqldump\u5c06\u5728\u503e\u5012\u7ed3\u679c\u524d\u88c5\u8f7d\u6574\u4e2a\u7ed3\u679c\u96c6\u5230\u5185\u5b58\u4e2d\uff0c\u5982\u679c\u4f60\u6b63\u5728\u503e\u5012\u4e00\u4e2a\u5927\u7684\u6570\u636e\u5e93\uff0c\u8fd9\u5c06\u53ef\u80fd\u662f\u4e00\u4e2a\u95ee\u9898\u3002\u00a0<\/p>\n<p>mysqldump\u652f\u6301\u4e0b\u5217\u9009\u9879\uff1a\u00a0<\/p>\n<p>&#8211;add-locks\u00a0<br \/>\n\u5728\u6bcf\u4e2a\u8868\u503e\u5012\u4e4b\u524d\u589e\u52a0LOCK\u00a0TABLES\u5e76\u4e14\u4e4b\u540eUNLOCK\u00a0TABLE\u3002(\u4e3a\u4e86\u4f7f\u5f97\u66f4\u5feb\u5730\u63d2\u5165\u5230MySQL)\u3002\u00a0<br \/>\n&#8211;add-drop-table\u00a0<br \/>\n\u5728\u6bcf\u4e2acreate\u8bed\u53e5\u4e4b\u524d\u589e\u52a0\u4e00\u4e2adrop\u00a0table\u3002\u00a0<br \/>\n&#8211;allow-keywords\u00a0<br \/>\n\u5141\u8bb8\u521b\u5efa\u662f\u5173\u952e\u8bcd\u7684\u5217\u540d\u5b57\u3002\u8fd9\u7531\u8868\u540d\u524d\u7f00\u4e8e\u6bcf\u4e2a\u5217\u540d\u505a\u5230\u3002\u00a0<br \/>\n-c,\u00a0&#8211;complete-insert\u00a0<br \/>\n\u4f7f\u7528\u5b8c\u6574\u7684insert\u8bed\u53e5(\u7528\u5217\u540d\u5b57)\u3002\u00a0<br \/>\n-C,\u00a0&#8211;compress\u00a0<br \/>\n\u5982\u679c\u5ba2\u6237\u548c\u670d\u52a1\u5668\u5747\u652f\u6301\u538b\u7f29\uff0c\u538b\u7f29\u4e24\u8005\u95f4\u6240\u6709\u7684\u4fe1\u606f\u3002\u00a0<br \/>\n&#8211;delayed\u00a0<br \/>\n\u7528INSERT\u00a0DELAYED\u547d\u4ee4\u63d2\u5165\u884c\u3002\u00a0<br \/>\n-e,\u00a0&#8211;extended-insert\u00a0<br \/>\n\u4f7f\u7528\u5168\u65b0\u591a\u884cINSERT\u8bed\u6cd5\u3002\uff08\u7ed9\u51fa\u66f4\u7d27\u7f29\u5e76\u4e14\u66f4\u5feb\u7684\u63d2\u5165\u8bed\u53e5\uff09\u00a0<br \/>\n-#,\u00a0&#8211;debug[=option_string]\u00a0<br \/>\n\u8ddf\u8e2a\u7a0b\u5e8f\u7684\u4f7f\u7528(\u4e3a\u4e86\u8c03\u8bd5)\u3002\u00a0<br \/>\n&#8211;help\u00a0<br \/>\n\u663e\u793a\u4e00\u6761\u5e2e\u52a9\u6d88\u606f\u5e76\u4e14\u9000\u51fa\u3002\u00a0<br \/>\n&#8211;fields-terminated-by=&#8230;\u00a0<br \/>\n\u3000\u00a0<br \/>\n&#8211;fields-enclosed-by=&#8230;\u00a0<br \/>\n\u3000\u00a0<br \/>\n&#8211;fields-optionally-enclosed-by=&#8230;\u00a0<br \/>\n\u3000\u00a0<br \/>\n&#8211;fields-escaped-by=&#8230;\u00a0<br \/>\n\u3000\u00a0<br \/>\n&#8211;fields-terminated-by=&#8230;\u00a0<br \/>\n\u8fd9\u4e9b\u9009\u62e9\u4e0e-T\u9009\u62e9\u4e00\u8d77\u4f7f\u7528\uff0c\u5e76\u4e14\u6709\u76f8\u5e94\u7684LOAD\u00a0DATA\u00a0INFILE\u5b50\u53e5\u76f8\u540c\u7684\u542b\u4e49\u3002\u89c17.16\u00a0LOAD\u00a0DATA\u00a0INFILE\u8bed\u6cd5\u3002\u00a0<br \/>\n-F,\u00a0&#8211;flush-logs\u00a0<br \/>\n\u5728\u5f00\u59cb\u503e\u5012\u524d\uff0c\u6d17\u6389\u5728MySQL\u670d\u52a1\u5668\u4e2d\u7684\u65e5\u5fd7\u6587\u4ef6\u3002\u00a0<br \/>\n-f,\u00a0&#8211;force,\u00a0<br \/>\n\u5373\u4f7f\u6211\u4eec\u5728\u4e00\u4e2a\u8868\u503e\u5012\u671f\u95f4\u5f97\u5230\u4e00\u4e2aSQL\u9519\u8bef\uff0c\u7ee7\u7eed\u3002\u00a0<br \/>\n-h,\u00a0&#8211;host=..\u00a0<br \/>\n\u4ece\u547d\u540d\u7684\u4e3b\u673a\u4e0a\u7684MySQL\u670d\u52a1\u5668\u503e\u5012\u6570\u636e\u3002\u7f3a\u7701\u4e3b\u673a\u662flocalhost\u3002\u00a0<br \/>\n-l,\u00a0&#8211;lock-tables.\u00a0<br \/>\n\u4e3a\u5f00\u59cb\u503e\u5012\u9501\u5b9a\u6240\u6709\u8868\u3002\u00a0<br \/>\n-t,\u00a0&#8211;no-create-info\u00a0<br \/>\n\u4e0d\u5199\u5165\u8868\u521b\u5efa\u4fe1\u606f(CREATE\u00a0TABLE\u8bed\u53e5\uff09\u00a0<br \/>\n-d,\u00a0&#8211;no-data\u00a0<br \/>\n\u4e0d\u5199\u5165\u8868\u7684\u4efb\u4f55\u884c\u4fe1\u606f\u3002\u5982\u679c\u4f60\u53ea\u60f3\u5f97\u5230\u4e00\u4e2a\u8868\u7684\u7ed3\u6784\u7684\u503e\u5012\uff0c\u8fd9\u662f\u5f88\u6709\u7528\u7684\uff01\u00a0<br \/>\n&#8211;opt\u00a0<br \/>\n\u540c&#8211;quick\u00a0&#8211;add-drop-table\u00a0&#8211;add-locks\u00a0&#8211;extended-insert\u00a0&#8211;lock-tables\u3002\u5e94\u8be5\u7ed9\u4f60\u4e3a\u8bfb\u5165\u4e00\u4e2aMySQL\u670d\u52a1\u5668\u7684\u5c3d\u53ef\u80fd\u6700\u5feb\u7684\u503e\u5012\u3002\u00a0<br \/>\n-pyour_pass,\u00a0&#8211;password[=your_pass]\u00a0<br \/>\n\u4e0e\u670d\u52a1\u5668\u8fde\u63a5\u65f6\u4f7f\u7528\u7684\u53e3\u4ee4\u3002\u5982\u679c\u4f60\u4e0d\u6307\u5b9a\u201c=your_pass\u201d\u90e8\u5206\uff0cmysqldump\u9700\u8981\u6765\u81ea\u7ec8\u7aef\u7684\u53e3\u4ee4\u3002\u00a0<br \/>\n-P\u00a0port_num,\u00a0&#8211;port=port_num\u00a0<br \/>\n\u4e0e\u4e00\u53f0\u4e3b\u673a\u8fde\u63a5\u65f6\u4f7f\u7528\u7684TCP\/IP\u7aef\u53e3\u53f7\u3002\uff08\u8fd9\u7528\u4e8e\u8fde\u63a5\u5230localhost\u4ee5\u5916\u7684\u4e3b\u673a\uff0c\u56e0\u4e3a\u5b83\u4f7f\u7528\u00a0Unix\u5957\u63a5\u5b57\u3002\uff09\u00a0<br \/>\n-q,\u00a0&#8211;quick\u00a0<br \/>\n\u4e0d\u7f13\u51b2\u67e5\u8be2\uff0c\u76f4\u63a5\u503e\u5012\u81f3stdout\uff1b\u4f7f\u7528mysql_use_result()\u505a\u5b83\u3002\u00a0<br \/>\n-S\u00a0\/path\/to\/socket,\u00a0&#8211;socket=\/path\/to\/socket\u00a0<br \/>\n\u4e0elocalhost\u8fde\u63a5\u65f6\uff08\u5b83\u662f\u7f3a\u7701\u4e3b\u673a)\u4f7f\u7528\u7684\u5957\u63a5\u5b57\u6587\u4ef6\u3002\u00a0<br \/>\n-T,\u00a0&#8211;tab=path-to-some-directory\u00a0<br \/>\n\u5bf9\u4e8e\u6bcf\u4e2a\u7ed9\u5b9a\u7684\u8868\uff0c\u521b\u5efa\u4e00\u4e2atable_name.sql\u6587\u4ef6\uff0c\u5b83\u5305\u542bSQL\u00a0CREATE\u00a0\u547d\u4ee4\uff0c\u548c\u4e00\u4e2atable_name.txt\u6587\u4ef6\uff0c\u5b83\u5305\u542b\u6570\u636e\u3002\u00a0\u6ce8\u610f\uff1a\u8fd9\u53ea\u6709\u5728mysqldump\u8fd0\u884c\u5728mysqld\u5b88\u62a4\u8fdb\u7a0b\u8fd0\u884c\u7684\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u7684\u65f6\u5019\u624d\u5de5\u4f5c\u3002.txt\u6587\u4ef6\u7684\u683c\u5f0f\u6839\u636e&#8211;fields- xxx\u548c&#8211;lines&#8211;xxx\u9009\u9879\u6765\u5b9a\u3002\u00a0<br \/>\n-u\u00a0user_name,\u00a0&#8211;user=user_name\u00a0<br \/>\n\u4e0e\u670d\u52a1\u5668\u8fde\u63a5\u65f6\uff0cMySQL\u4f7f\u7528\u7684\u7528\u6237\u540d\u3002\u7f3a\u7701\u503c\u662f\u4f60\u7684Unix\u767b\u5f55\u540d\u3002\u00a0<br \/>\n-O\u00a0var=option,\u00a0&#8211;set-variable\u00a0var=option\u00a0<br \/>\n\u8bbe\u7f6e\u4e00\u4e2a\u53d8\u91cf\u7684\u503c\u3002\u53ef\u80fd\u7684\u53d8\u91cf\u88ab\u5217\u5728\u4e0b\u9762\u3002\u00a0<br \/>\n-v,\u00a0&#8211;verbose\u00a0<br \/>\n\u5197\u957f\u6a21\u5f0f\u3002\u6253\u5370\u51fa\u7a0b\u5e8f\u6240\u505a\u7684\u66f4\u591a\u7684\u4fe1\u606f\u3002\u00a0<br \/>\n-V,\u00a0&#8211;version\u00a0<br \/>\n\u6253\u5370\u7248\u672c\u4fe1\u606f\u5e76\u4e14\u9000\u51fa\u3002\u00a0<br \/>\n-w,\u00a0&#8211;where=&#8217;where-condition&#8217;\u00a0<br \/>\n\u53ea\u503e\u5012\u88ab\u9009\u62e9\u4e86\u7684\u8bb0\u5f55\uff1b\u6ce8\u610f\u5f15\u53f7\u662f\u5f3a\u5236\u7684\uff01\u00a0<br \/>\n&amp;quot;&#8211;where=user=&#8217;jimf&#8217;&amp;quot;\u00a0&amp;quot;-wuserid&amp;gt;1&amp;quot;\u00a0&amp;quot;-wuserid&amp;lt;1&amp;quot;\u00a0<\/p>\n<p>\u6700\u5e38\u89c1\u7684mysqldump\u4f7f\u7528\u53ef\u80fd\u5236\u4f5c\u6574\u4e2a\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u5907\u4efd\uff1a\u00a0<\/p>\n<p>mysqldump\u00a0&#8211;opt\u00a0database\u00a0&amp;gt;\u00a0backup-file.sql\u00a0<\/p>\n<p>\u4f46\u662f\u5b83\u5bf9\u7528\u6765\u81ea\u4e8e\u4e00\u4e2a\u6570\u636e\u5e93\u7684\u4fe1\u606f\u5145\u5b9e\u53e6\u5916\u4e00\u4e2aMySQL\u6570\u636e\u5e93\u4e5f\u662f\u6709\u7528\u7684\uff1a\u00a0<\/p>\n<p>mysqldump\u00a0&#8211;opt\u00a0database\u00a0|\u00a0mysql\u00a0&#8211;host=remote-host\u00a0-C\u00a0database\u00a0<\/p>\n<p>\u5728\u4e16\u7eaa\u8bba\u575b\u00a0\u6709\u4eba\u95ee\u5230\u5982\u4f55\u5728windows\u4e0b\u4f7f\u7528mysqldump\u5bfc\u5165\u6570\u636e\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a\u00a0<\/p>\n<p>\u5047\u5982mysql\u5b89\u88c5\u5728c:\\mysql\u4e0b\uff1a\u00a0<br \/>\n\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u8fdb\u5165\u5230\u8be5\u76ee\u5f55\u7684bin\u4e0b\uff1acd\u00a0mysql\\bin\u00a0<br \/>\n\u7136\u540e\u6572\u5165\u547d\u4ee4\uff1amysql\u00a0-h\u00a0192.168.1.5\u00a0-u\u00a0root\u00a0-p\u00a0flash\u00a0&amp;lt;\u00a0e:\\flash.sql\u00a0<br \/>\n\u6b64\u5904\u6ce8\u610f\uff1a\uff0dh\u547d\u4ee4\u5982\u679c\u662f\u672c\u673a\u6700\u597d\u8ddfIP\u5730\u5740\uff0c\u662f\u8fdc\u7a0b\u4e3b\u673a\uff0c\u5f53\u7136\u5c31\u662f\u4e3b\u673a\u7684IP\u5730\u5740\u4e86\uff0c\u56e0\u4e3amysql\u9ed8\u8ba4\u7684localhost\u7684root\u7528\u6237\u6709\u4e2a\u5bc6\u7801\uff0c\uff0dp\u540e\u8ddfmysql\u7684\u5bc6\u7801\uff0c\u4e2d\u95f4\u6ca1\u6709\u7a7a\u683c\uff0cflash\u4ee3\u8868\u4f60\u8981\u5bfc\u5165\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\uff1b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u7528\u7a0b\u5e8f\uff0c\u4e3a\u5907\u4efd\u6216\u4e3a\u628a\u6570\u636e\u8f6c\u79fb\u5230\u53e6\u5916\u7684SQL\u670d\u52a1\u5668\u4e0a\u503e\u5012\u4e00\u4e2a\u6570\u636e\u5e93&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":0,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}