{"id":588,"date":"2017-08-09T13:42:41","date_gmt":"2017-08-09T13:42:41","guid":{"rendered":"http:\/\/daca41214b39c5dc66674d09081940f0"},"modified":"2019-06-22T17:27:50","modified_gmt":"2019-06-22T09:27:50","slug":"mysqldump","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/588","title":{"rendered":"mysqldump"},"content":{"rendered":"<p><span style=\"font-size: 12pt;\">mysqldump \u7528\u6765\u8f6c\u50a8\u6570\u636e\u5e93\u6216\u641c\u96c6\u6570\u636e\u5e93\u8fdb\u884c\u5907\u4efd\u6216\u5c06\u6570\u636e\u8f6c\u5b58\u4e3a\u6587\u4ef6<\/span><br \/>\n<span style=\"font-size: 12pt;\"> \u5982\u5728\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u5907\u4efd\u5e76\u4e14\u8868\u5747\u4e3aMyISAM\u8868\uff0c\u5e94\u8003\u8651\u4f7f\u7528mysqlhotcopy\uff0c\u56e0\u4e3a\u53ef\u4ee5\u66f4\u5feb\u5730\u8fdb\u884c\u5907\u4efd\u548c\u6062\u590d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> <b>1.mysqldump\u7684\u51e0\u79cd\u5e38\u7528\u65b9\u6cd5\uff1a<\/b><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff081\uff09<b>\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93<\/b>(\u5305\u62ec\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> mysqldump -u username -p dbname &gt; dbname.sql <\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff082\uff09<b>\u5bfc\u51fa\u6570\u636e\u5e93\u7ed3\u6784<\/b>\uff08\u4e0d\u542b\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> mysqldump -u username -p -d dbname &gt; dbname.sql <\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff083\uff09<b>\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u67d0\u5f20\u6570\u636e\u8868<\/b>\uff08\u5305\u542b\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> mysqldump -u username -p dbname tablename &gt; tablename.sql <\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff084\uff09<b>\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u67d0\u5f20\u6570\u636e\u8868\u7684\u8868\u7ed3\u6784<\/b>\uff08\u4e0d\u542b\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> mysqldump -u username -p -d dbname tablename &gt; tablename.sql <\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff085\uff09<b>\u8f6c\u50a8\u51e0\u4e2a\u6570\u636e\u5e93<\/b><\/span><br \/>\n<span style=\"font-size: 12pt;\"> mysqldump ---database db_name1 [db_name2 ...] &gt; my_databases.sql <\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff086\uff09<b>\u8f6c\u50a8\u5168\u5e93<\/b><\/span><br \/>\n<span style=\"font-size: 12pt;\"> mysqldump --all-databases &gt; all_databases.sql <\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \uff087\uff09<b>Master\/Slave \u6570\u636e\u8f6c\u79fb<\/b><\/span><br \/>\n<span style=\"font-size: 12pt;\"> mysqldump -uroot -ppassword --opt --default-character-set=utf8 --extended-insert=true --single-transaction -R --flush-logs --master-data=1 --all-databases &gt; 20170809.sql<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><i> \u6ce8\uff1a\u67e5\u8be2file\u548cposition\u7684\u503c grep -i \"change master to\" <\/i><i>20170809.sql<br \/>\nwindows find \"CHANGE MASTER TO \" d:\\\\20170809.sql<br \/>\n<\/i><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> 2. <b>\u8fd8\u539f\u6570\u636e\u5230\u5e93<\/b>\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">mysql&gt; source \/home\/dba\/dbname.sql<\/span><br \/>\n<span style=\"font-size: 12pt;\"> shell&gt; mysql db_name &lt; backup-file.sql<\/span><br \/>\n<span style=\"font-size: 12pt;\"> shell&gt; mysqldump --opt db_name &gt; backup-file.sql<\/p>\n<p><em>\u5e93\u5185\u5177\u6709\u51fd\u6570\u65f6\u8003\u8651\uff1a<br \/>\nSET GLOBAL log_bin_trust_function_creators = 1;<br \/>\n<\/em>source \/home\/dba\/dbname.sql<br \/>\n<em>SET GLOBAL log_bin_trust_function_creators = 0;<\/em><br \/>\n<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> <b>3. mysqldump\u652f\u6301\u7684\u9009\u9879<\/b><\/span><br \/>\n<span style=\"font-size: 12pt;\"> \u5982\u679c\u8fd0\u884cmysqldump\u6ca1\u6709--quick\u6216--opt\u9009\u9879\uff0cmysqldump\u5728\u8f6c\u50a8\u7ed3\u679c\u524d\u5c06\u6574\u4e2a\u7ed3\u679c\u96c6\u88c5\u5165\u5185\u5b58\u3002\u5982\u679c\u8f6c\u50a8\u5927\u6570\u636e\u5e93\u53ef\u80fd\u4f1a\u51fa\u73b0\u95ee\u9898\u3002\u8be5\u9009\u9879\u9ed8\u8ba4\u542f\u7528\uff0c\u4f46\u53ef\u4ee5\u7528--skip-opt\u7981\u7528\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5982\u679c\u4f7f\u7528\u6700\u65b0\u7248\u672c\u7684mysqldump\u7a0b\u5e8f\u751f\u6210\u4e00\u4e2a\u8f6c\u50a8\u91cd\u88c5\u5230\u5f88\u65e7\u7248\u672c\u7684MySQL\u670d\u52a1\u5668\u4e2d\uff0c\u4e0d\u5e94\u4f7f\u7528--opt\u6216-e\u9009\u9879\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> mysqldump\u652f\u6301\u4e0b\u9762\u7684\u9009\u9879\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 ---help\uff0c-\uff1f<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u663e\u793a\u5e2e\u52a9\u6d88\u606f\u5e76\u9000\u51fa\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --add-drop--database<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728\u6bcf\u4e2aCREATE DATABASE\u8bed\u53e5\u524d\u6dfb\u52a0DROP DATABASE\u8bed\u53e5\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --add-drop-tables<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728\u6bcf\u4e2aCREATE TABLE\u8bed\u53e5\u524d\u6dfb\u52a0DROP TABLE\u8bed\u53e5\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --add-locking<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u7528LOCK TABLES\u548cUNLOCK TABLES\u8bed\u53e5\u5f15\u7528\u6bcf\u4e2a\u8868\u8f6c\u50a8\u3002\u91cd\u8f7d\u8f6c\u50a8\u6587\u4ef6\u65f6\u63d2\u5165\u5f97\u66f4\u5feb\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --all--database\uff0c-A<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8f6c\u50a8\u6240\u6709\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\u3002\u4e0e\u4f7f\u7528---database\u9009\u9879\u76f8\u540c\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u547d\u540d\u6240\u6709\u6570\u636e\u5e93\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --allow-keywords<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5141\u8bb8\u521b\u5efa\u5173\u952e\u5b57\u5217\u540d\u3002\u5e94\u5728\u6bcf\u4e2a\u5217\u540d\u524d\u9762\u52a0\u4e0a\u8868\u540d\u524d\u7f00\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 ---comments[={0|1}]<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5982\u679c\u8bbe\u7f6e\u4e3a 0\uff0c\u7981\u6b62\u8f6c\u50a8\u6587\u4ef6\u4e2d\u7684\u5176\u5b83\u4fe1\u606f\uff0c\u4f8b\u5982\u7a0b\u5e8f\u7248\u672c\u3001\u670d\u52a1\u5668\u7248\u672c\u548c\u4e3b\u673a\u3002--skip\u2014comments\u4e0e---comments=0\u7684\u7ed3\u679c\u76f8\u540c\u3002 \u9ed8\u8ba4\u503c\u4e3a1\uff0c\u5373\u5305\u62ec\u989d\u5916\u4fe1\u606f\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --compact<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4ea7\u751f\u5c11\u91cf\u8f93\u51fa\u3002\u8be5\u9009\u9879\u7981\u7528\u6ce8\u91ca\u5e76\u542f\u7528--skip-add-drop-tables\u3001--no-set-names\u3001--skip-disable-keys\u548c--skip-add-locking\u9009\u9879\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --compatible=name<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4ea7\u751f\u4e0e\u5176\u5b83\u6570\u636e\u5e93\u7cfb\u7edf\u6216\u65e7\u7684MySQL\u670d\u52a1\u5668\u66f4\u517c\u5bb9\u7684\u8f93\u51fa\u3002\u503c\u53ef\u4ee5\u4e3aansi\u3001mysql323\u3001mysql40\u3001postgresql\u3001oracle\u3001mssql\u3001db2\u3001maxdb\u3001no_key_options\u3001no_tables_options\u6216\u8005no_field_options\u3002\u8981\u4f7f\u7528\u51e0\u4e2a\u503c\uff0c\u7528\u9017\u53f7\u5c06\u5b83\u4eec\u9694\u5f00\u3002\u8fd9\u4e9b\u503c\u4e0e\u8bbe\u7f6e\u670d\u52a1\u5668SQL\u6a21\u5f0f\u7684\u76f8\u5e94\u9009\u9879\u6709\u76f8\u540c\u7684\u542b\u4e49\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u4e0d\u80fd\u4fdd\u8bc1\u540c\u5176\u5b83\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u517c\u5bb9\u6027\u3002\u5b83\u53ea\u542f\u7528\u90a3\u4e9b\u76ee\u524d\u80fd\u591f\u4f7f\u8f6c\u50a8\u8f93\u51fa\u66f4\u517c\u5bb9\u7684SQL\u6a21\u5f0f\u503c\u3002\u4f8b\u5982\uff0c--compatible=oracle \u4e0d\u6620\u5c04Oracle\u7c7b\u578b\u6216\u4f7f\u7528Oracle\u6ce8\u91ca\u8bed\u6cd5\u7684\u6570\u636e\u7c7b\u578b\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --complete-insert\uff0c-c<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f7f\u7528\u5305\u62ec\u5217\u540d\u7684\u5b8c\u6574\u7684INSERT\u8bed\u53e5\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --compress\uff0c-C<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u538b\u7f29\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u53d1\u9001\u7684\u6240\u6709\u4fe1\u606f\uff08\u5982\u679c\u4e8c\u8005\u5747\u652f\u6301\u538b\u7f29\uff09\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --create-option<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728CREATE TABLE\u8bed\u53e5\u4e2d\u5305\u62ec\u6240\u6709MySQL\u8868\u9009\u9879\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 ---database\uff0c-B<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8f6c\u50a8\u51e0\u4e2a\u6570\u636e\u5e93\u3002\u901a\u5e38\u60c5\u51b5\uff0cmysqldump\u5c06\u547d\u4ee4\u884c\u4e2d\u7684\u7b2c1\u4e2a\u540d\u5b57\u53c2\u91cf\u770b\u4f5c\u6570\u636e\u5e93\u540d\uff0c\u540e\u9762\u7684\u540d\u770b\u4f5c\u8868\u540d\u3002\u4f7f\u7528\u8be5\u9009\u9879\uff0c\u5b83\u5c06\u6240\u6709\u540d\u5b57\u53c2\u91cf\u770b\u4f5c\u6570\u636e\u5e93\u540d\u3002CREATE DATABASE IF NOT EXISTS db_name\u548cUSE db_name\u8bed\u53e5\u5305\u542b\u5728\u6bcf\u4e2a\u65b0\u6570\u636e\u5e93\u524d\u7684\u8f93\u51fa\u4e2d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 ---debug[=debug_options]\uff0c-# [debug_options]<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5199\u8c03\u8bd5\u65e5\u5fd7\u3002debug_options\u5b57\u7b26\u4e32\u901a\u5e38\u4e3a'd:t:o,file_name'\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --default-character-set=charset<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f7f\u7528charsetas\u9ed8\u8ba4\u5b57\u7b26\u96c6\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a\uff0cmysqldump\u4f7f\u7528utf8\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --delayed-insert<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f7f\u7528INSERT DELAYED\u8bed\u53e5\u63d2\u5165\u884c\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --delete-master-logs<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728\u4e3b\u590d\u5236\u670d\u52a1\u5668\u4e0a\uff0c\u5b8c\u6210\u8f6c\u50a8\u64cd\u4f5c\u540e\u5220\u9664\u4e8c\u8fdb\u5236\u65e5\u5fd7\u3002\u8be5\u9009\u9879\u81ea\u52a8\u542f\u7528--master-data\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --disable-keys\uff0c-K<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5bf9\u4e8e\u6bcf\u4e2a\u8868\uff0c\u7528\/*!40000 ALTER TABLE tbl_name DISABLE KEYS *\/;\u548c\/*!40000 ALTER TABLE tbl_name ENABLE KEYS *\/;\u8bed\u53e5\u5f15\u7528INSERT\u8bed\u53e5\u3002\u8fd9\u6837\u53ef\u4ee5\u66f4\u5feb\u5730\u88c5\u8f7d\u8f6c\u50a8\u6587\u4ef6\uff0c\u56e0\u4e3a\u5728\u63d2\u5165\u6240\u6709\u884c\u540e\u521b\u5efa\u7d22\u5f15\u3002\u8be5\u9009\u9879\u53ea\u9002\u5408MyISAM\u8868\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --extended-insert\uff0c-e<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f7f\u7528\u5305\u62ec\u51e0\u4e2aVALUES\u5217\u8868\u7684\u591a\u884cINSERT\u8bed\u6cd5\u3002\u8fd9\u6837\u4f7f\u8f6c\u50a8\u6587\u4ef6\u66f4\u5c0f\uff0c\u91cd\u8f7d\u6587\u4ef6\u65f6\u53ef\u4ee5\u52a0\u901f\u63d2\u5165\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --fields-terminated-by=...\uff0c--fields-enclosed-by=...\uff0c--fields-optionally-enclosed-by=...\uff0c--fields-escaped-by=...\uff0c--\u884c-terminated-by=...<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8fd9\u4e9b\u9009\u9879\u7ed3\u5408-T\u9009\u9879\u4f7f\u7528\uff0c\u4e0eLOAD DATA INFILE\u7684\u76f8\u5e94\u5b50\u53e5\u6709\u76f8\u540c\u7684\u542b\u4e49\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --first-slave\uff0c-x<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4e0d\u8d5e\u6210\u4f7f\u7528\uff0c\u73b0\u5728\u91cd\u65b0\u547d\u540d\u4e3a--lock-all-tables\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --flush-logs\uff0c-F<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5f00\u59cb\u8f6c\u50a8\u524d\u5237\u65b0MySQL\u670d\u52a1\u5668\u65e5\u5fd7\u6587\u4ef6\u3002\u8be5\u9009\u9879\u8981\u6c42RELOAD\u6743\u9650\u3002\u8bf7\u6ce8\u610f\u5982\u679c\u7ed3\u5408--all--database(\u6216-A)\u9009\u9879\u4f7f\u7528\u8be5\u9009\u9879\uff0c\u6839\u636e\u6bcf\u4e2a\u8f6c\u50a8\u7684\u6570\u636e\u5e93\u5237\u65b0\u65e5\u5fd7\u3002\u4f8b\u5916\u60c5\u51b5\u662f\u5f53\u4f7f\u7528--lock-all-tables\u6216--master-data\u7684\u65f6\u5019\uff1a\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e5\u5fd7\u53ea\u5237\u65b0\u4e00\u6b21\uff0c\u5728\u6240\u6709 \u8868\u88ab\u9501\u5b9a\u540e\u5237\u65b0\u3002\u5982\u679c\u4f60\u60f3\u8981\u540c\u65f6\u8f6c\u50a8\u548c\u5237\u65b0\u65e5\u5fd7\uff0c\u5e94\u4f7f\u7528--flush-logs\u8fde\u540c--lock-all-tables\u6216--master-data\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --force\uff0c-f<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728\u8868\u8f6c\u50a8\u8fc7\u7a0b\u4e2d\uff0c\u5373\u4f7f\u51fa\u73b0SQL\u9519\u8bef\u4e5f\u7ee7\u7eed\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --host=host_name\uff0c-h host_name<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4ece\u7ed9\u5b9a\u4e3b\u673a\u7684MySQL\u670d\u52a1\u5668\u8f6c\u50a8\u6570\u636e\u3002\u9ed8\u8ba4\u4e3b\u673a\u662flocalhost\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --hex-blob<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f7f\u7528\u5341\u516d\u8fdb\u5236\u7b26\u53f7\u8f6c\u50a8\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u5217(\u4f8b\u5982\uff0c'abc' \u53d8\u4e3a0x616263)\u3002\u5f71\u54cd\u5230\u7684\u5217\u6709BINARY\u3001VARBINARY\u3001BLOB\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --lock-all-tables\uff0c-x<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u6240\u6709\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\u52a0\u9501\u3002\u5728\u6574\u4f53\u8f6c\u50a8\u8fc7\u7a0b\u4e2d\u901a\u8fc7\u5168\u5c40\u8bfb\u9501\u5b9a\u6765\u5b9e\u73b0\u3002\u8be5\u9009\u9879\u81ea\u52a8\u5173\u95ed--single-transaction\u548c--lock-tables\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --lock-tables\uff0c-l<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5f00\u59cb\u8f6c\u50a8\u524d\u9501\u5b9a\u6240\u6709\u8868\u3002\u7528READ LOCAL\u9501\u5b9a\u8868\u4ee5\u5141\u8bb8\u5e76\u884c\u63d2\u5165MyISAM\u8868\u3002\u5bf9\u4e8e\u4e8b\u52a1\u8868\u4f8b\u5982InnoDB\u548cBDB\uff0c--single-transaction\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u9009\u9879\uff0c\u56e0\u4e3a\u5b83\u4e0d\u6839\u672c\u9700\u8981\u9501\u5b9a\u8868\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8bf7\u6ce8\u610f\u5f53\u8f6c\u50a8\u591a\u4e2a\u6570\u636e\u5e93\u65f6\uff0c--lock-tables\u5206\u522b\u4e3a\u6bcf\u4e2a\u6570\u636e\u5e93\u9501\u5b9a\u8868\u3002\u56e0\u6b64\uff0c\u8be5\u9009\u9879\u4e0d\u80fd\u4fdd\u8bc1\u8f6c\u50a8\u6587\u4ef6\u4e2d\u7684\u8868\u5728\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u903b\u8f91\u4e00\u81f4\u6027\u3002\u4e0d\u540c\u6570\u636e\u5e93\u8868\u7684\u8f6c\u50a8\u72b6\u6001\u53ef\u4ee5\u5b8c\u5168\u4e0d\u540c\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --master-data[=value]<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u5c06\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u4f4d\u7f6e\u548c\u6587\u4ef6\u540d\u5199\u5165\u5230\u8f93\u51fa\u4e2d\u3002\u8be5\u9009\u9879\u8981\u6c42\u6709RELOAD\u6743\u9650\uff0c\u5e76\u4e14\u5fc5\u987b\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u3002\u5982\u679c\u8be5\u9009\u9879\u503c\u7b49\u4e8e1\uff0c\u4f4d\u7f6e\u548c\u6587\u4ef6\u540d\u88ab\u5199\u5165CHANGE MASTER\u8bed\u53e5\u5f62\u5f0f\u7684\u8f6c\u50a8\u8f93\u51fa\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u8be5SQL\u8f6c\u50a8\u4e3b\u670d\u52a1\u5668\u4ee5\u8bbe\u7f6e\u4ece\u670d\u52a1\u5668\uff0c\u4ece\u670d\u52a1\u5668\u4ece\u4e3b\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u6b63\u786e\u4f4d\u7f6e\u5f00\u59cb\u3002\u5982\u679c\u9009\u9879\u503c\u7b49\u4e8e2\uff0cCHANGE MASTER\u8bed\u53e5\u88ab\u5199\u6210SQL\u6ce8\u91ca\u3002\u5982\u679cvalue\u88ab\u7701\u7565\uff0c\u8fd9\u662f\u9ed8\u8ba4\u52a8\u4f5c\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> --master-data\u9009\u9879\u542f\u7528--lock-all-tables\uff0c\u9664\u975e\u8fd8\u6307\u5b9a--single-transaction(\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ea\u5728\u521a\u5f00\u59cb\u8f6c\u50a8\u65f6\u77ed\u65f6\u95f4\u83b7\u5f97\u5168\u5c40\u8bfb\u9501\u5b9a\u3002\u53c8\u89c1--single-transaction\u3002\u5728\u4efb\u4f55\u4e00\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e5\u5fd7\u76f8\u5173\u52a8\u4f5c\u53d1\u751f\u5728\u8f6c\u50a8\u65f6\u3002\u8be5\u9009\u9879\u81ea\u52a8\u5173\u95ed--lock-tables\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --no-create-db\uff0c-n<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u7981\u7528CREATE DATABASE \/*!32312 IF NOT EXISTS*\/ db_name\u8bed\u53e5\uff0c\u5982\u679c\u7ed9\u51fa---database\u6216--all--database\u9009\u9879\uff0c\u5219\u5305\u542b\u5230\u8f93\u51fa\u4e2d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --no-create-info\uff0c-t<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4e0d\u5199\u91cd\u65b0\u521b\u5efa\u6bcf\u4e2a\u8f6c\u50a8\u8868\u7684CREATE TABLE\u8bed\u53e5\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --no-data\uff0c-d<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4e0d\u5199\u8868\u7684\u4efb\u4f55\u884c\u4fe1\u606f\u3002\u5982\u679c\u4f60\u53ea\u60f3\u8f6c\u50a8\u8868\u7684\u7ed3\u6784\u8fd9\u5f88\u6709\u7528\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --opt<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u662f\u901f\u8bb0\uff1b\u7b49\u540c\u4e8e\u6307\u5b9a --add-drop-tables--add-locking --create-option --disable-keys--extended-insert --lock-tables --quick --set-charset\u3002\u5b83\u53ef\u4ee5\u7ed9\u51fa\u5f88\u5feb\u7684\u8f6c\u50a8\u64cd\u4f5c\u5e76\u4ea7\u751f\u4e00\u4e2a\u53ef\u4ee5\u5f88\u5feb\u88c5\u5165MySQL\u670d\u52a1\u5668\u7684\u8f6c\u50a8\u6587\u4ef6\u3002\u8be5\u9009\u9879\u9ed8\u8ba4\u5f00\u542f\uff0c\u4f46\u53ef\u4ee5\u7528--skip-opt\u7981\u7528\u3002\u8981\u60f3\u53ea\u7981\u7528\u786e\u4fe1\u7528-opt\u542f\u7528\u7684\u9009\u9879\uff0c\u4f7f\u7528--skip\u5f62\u5f0f\uff1b\u4f8b\u5982\uff0c--skip-add-drop-tables\u6216--skip-quick\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --password[=password]\uff0c-p[password]<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8fde\u63a5\u670d\u52a1\u5668\u65f6\u4f7f\u7528\u7684\u5bc6\u7801\u3002\u5982\u679c\u4f60\u4f7f\u7528\u77ed\u9009\u9879\u5f62\u5f0f(-p)\uff0c\u4e0d\u80fd\u5728\u9009\u9879\u548c\u5bc6\u7801\u4e4b\u95f4\u6709\u4e00\u4e2a\u7a7a\u683c\u3002\u5982\u679c\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u5ffd\u7565\u4e86--password\u6216-p\u9009\u9879\u540e\u9762\u7684 \u5bc6\u7801\u503c\uff0c\u5c06\u63d0\u793a\u4f60\u8f93\u5165\u4e00\u4e2a\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --port=port_num\uff0c-P port_num<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u7528\u4e8e\u8fde\u63a5\u7684TCP\/IP\u7aef\u53e3\u53f7\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --protocol={TCP | SOCKET | PIPE | MEMORY}<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f7f\u7528\u7684\u8fde\u63a5\u534f\u8bae\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --quick\uff0c-q<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u7528\u4e8e\u8f6c\u50a8\u5927\u7684\u8868\u3002\u5b83\u5f3a\u5236mysqldump\u4ece\u670d\u52a1\u5668\u4e00\u6b21\u4e00\u884c\u5730\u68c0\u7d22\u8868\u4e2d\u7684\u884c\u800c\u4e0d\u662f\u68c0\u7d22\u6240\u6709\u884c\u5e76\u5728\u8f93\u51fa\u524d\u5c06\u5b83\u7f13\u5b58\u5230\u5185\u5b58\u4e2d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --quote-names\uff0c-Q<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u7528\u2018`\u2019\u5b57\u7b26\u5f15\u7528\u6570\u636e\u5e93\u3001\u8868\u548c\u5217\u540d\u3002\u5982\u679c\u670d\u52a1\u5668SQL\u6a21\u5f0f\u5305\u62ecANSI_QUOTES\u9009\u9879\uff0c\u7528\u2018\"\u2019\u5b57\u7b26\u5f15\u7528\u540d\u3002\u9ed8\u8ba4\u542f\u7528\u8be5\u9009\u9879\u3002\u53ef\u4ee5\u7528--skip-quote-names\u7981\u7528\uff0c\u4f46\u8be5\u9009\u9879\u5e94\u8ddf\u5728\u5176\u5b83\u9009\u9879\u540e\u9762\uff0c\u4f8b\u5982\u53ef\u4ee5\u542f\u7528--quote-names\u7684--compatible\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --result-file=file\uff0c-r file<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5c06\u8f93\u51fa\u8f6c\u5411\u7ed9\u5b9a\u7684\u6587\u4ef6\u3002\u8be5\u9009\u9879\u5e94\u7528\u5728Windows\u4e2d\uff0c\u56e0\u4e3a\u5b83\u7981\u6b62\u5c06\u65b0\u884c\u2018\\n\u2019\u5b57\u7b26\u8f6c\u6362\u4e3a\u2018\\r\\n\u2019\u56de\u8f66\u3001\u8fd4\u56de\/\u65b0\u884c\u5e8f\u5217\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --routines\uff0c-R<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728\u8f6c\u50a8\u7684\u6570\u636e\u5e93\u4e2d\u8f6c\u50a8\u5b58\u50a8\u7a0b\u5e8f(\u51fd\u6570\u548c\u7a0b\u5e8f)\u3002\u4f7f\u7528---routines\u4ea7\u751f\u7684\u8f93\u51fa\u5305\u542bCREATE PROCEDURE\u548cCREATE FUNCTION\u8bed\u53e5\u4ee5\u91cd\u65b0\u521b\u5efa\u5b50\u7a0b\u5e8f\u3002\u4f46\u662f\uff0c\u8fd9\u4e9b\u8bed\u53e5\u4e0d\u5305\u62ec\u5c5e\u6027\uff0c\u4f8b\u5982\u5b50\u7a0b\u5e8f\u5b9a\u4e49\u8005\u6216\u521b\u5efa\u548c\u4fee\u6539\u65f6\u95f4\u6233\u3002\u8fd9\u8bf4\u660e\u5f53\u91cd\u8f7d\u5b50\u7a0b\u5e8f\u65f6\uff0c\u5bf9\u5b83\u4eec\u8fdb\u884c\u521b\u5efa\u65f6\u5b9a\u4e49\u8005\u5e94\u8bbe\u7f6e\u4e3a\u91cd\u8f7d\u7528\u6237\uff0c\u65f6\u95f4\u6233\u7b49\u4e8e\u91cd\u8f7d\u65f6\u95f4\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5982\u679c\u4f60\u9700\u8981\u521b\u5efa\u7684\u5b50\u7a0b\u5e8f\u4f7f\u7528\u539f\u6765\u7684\u5b9a\u4e49\u8005\u548c\u65f6\u95f4\u6233\u5c5e\u6027\uff0c\u4e0d\u4f7f\u7528--routines\u3002\u76f8\u53cd\uff0c\u4f7f\u7528\u4e00\u4e2a\u5177\u6709mysql\u6570\u636e\u5e93\u76f8\u5e94\u6743\u9650\u7684MySQL\u8d26\u6237\u76f4\u63a5\u8f6c\u50a8\u548c\u91cd\u8f7dmysql.proc\u8868\u7684\u5185\u5bb9\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u5728MySQL 5.1.2\u4e2d\u6dfb\u52a0\u8fdb\u6765\u3002\u5728\u6b64\u4e4b\u524d\uff0c\u5b58\u50a8\u7a0b\u5e8f\u4e0d\u8f6c\u50a8\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --set-charset<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5c06SET NAMES default_character_set\u52a0\u5230\u8f93\u51fa\u4e2d\u3002\u8be5\u9009\u9879\u9ed8\u8ba4\u542f\u7528\u3002\u8981\u60f3\u7981\u7528SET NAMES\u8bed\u53e5\uff0c\u4f7f\u7528--skip-set-charset\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --single-transaction<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8be5\u9009\u9879\u4ece\u670d\u52a1\u5668\u8f6c\u50a8\u6570\u636e\u4e4b\u524d\u53d1\u51fa\u4e00\u4e2aBEGIN SQL\u8bed\u53e5\u3002\u5b83\u53ea\u9002\u7528\u4e8e\u4e8b\u52a1\u8868\uff0c\u4f8b\u5982InnoDB\u548cBDB\uff0c\u56e0\u4e3a\u7136\u540e\u5b83\u5c06\u5728\u53d1\u51faBEGIN\u800c\u6ca1\u6709\u963b\u585e\u4efb\u4f55\u5e94\u7528\u7a0b\u5e8f\u65f6\u8f6c\u50a8\u4e00\u81f4\u7684\u6570\u636e\u5e93\u72b6\u6001\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5f53\u4f7f\u7528\u8be5\u9009\u9879\u65f6\uff0c\u5e94\u8bb0\u4f4f\u53ea\u6709InnoDB\u8868\u80fd\u4ee5\u4e00\u81f4\u7684\u72b6\u6001\u88ab\u8f6c\u50a8\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u8be5\u9009\u9879\u65f6\u4efb\u4f55\u8f6c\u50a8\u7684MyISAM\u6216HEAP\u8868\u4ecd\u7136\u53ef\u4ee5\u66f4\u6539\u72b6\u6001\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> --single-transaction\u9009\u9879\u548c--lock-tables\u9009\u9879\u662f\u4e92\u65a5\u7684\uff0c\u56e0\u4e3aLOCK TABLES\u4f1a\u4f7f\u4efb\u4f55\u6302\u8d77\u7684\u4e8b\u52a1\u9690\u542b\u63d0\u4ea4\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8981\u60f3\u8f6c\u50a8\u5927\u7684\u8868\uff0c\u5e94\u7ed3\u5408--quick\u4f7f\u7528\u8be5\u9009\u9879\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --socket=path\uff0c-S path<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5f53\u8fde\u63a5localhost(\u4e3a\u9ed8\u8ba4\u4e3b\u673a)\u65f6\u4f7f\u7528\u7684\u5957\u63a5\u5b57\u6587\u4ef6\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --skip--comments<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u53c2\u89c1---comments\u9009\u9879\u7684\u63cf\u8ff0\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --tab=path\uff0c-T path<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4ea7\u751ftab\u5206\u5272\u7684\u6570\u636e\u6587\u4ef6\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u8f6c\u50a8\u7684\u8868\uff0cmysqldump\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u521b\u5efa\u8868\u7684CREATE TABLE\u8bed\u53e5\u7684tbl_name.sql\u6587\u4ef6\uff0c\u548c\u4e00\u4e2a\u5305\u542b\u5176\u6570\u636e\u7684tbl_name.txt\u6587\u4ef6\u3002\u9009\u9879\u503c\u4e3a\u5199\u5165\u6587\u4ef6\u7684\u76ee\u5f55\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u9ed8\u8ba4\u60c5\u51b5\uff0c.txt\u6570\u636e\u6587\u4ef6\u7684\u683c\u5f0f\u662f\u5728\u5217\u503c\u548c\u6bcf\u884c\u540e\u9762\u7684\u65b0\u884c\u4e4b\u95f4\u4f7f\u7528tab\u5b57\u7b26\u3002\u53ef\u4ee5\u4f7f\u7528--fields-xxx\u548c--\u884c--xxx\u9009\u9879\u660e\u663e\u6307\u5b9a\u683c\u5f0f\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u6ce8\u91ca\uff1a\u8be5\u9009\u9879\u53ea\u9002\u7528\u4e8emysqldump\u4e0emysqld\u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8fd0\u884c\u65f6\u3002\u4f60\u5fc5\u987b\u5177\u6709FILE\u6743\u9650\uff0c\u5e76\u4e14\u670d\u52a1\u5668\u5fc5\u987b\u6709\u5728\u4f60\u6307\u5b9a\u7684\u76ee\u5f55\u4e2d\u6709\u5199\u6587\u4ef6\u7684\u8bb8\u53ef\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --tables<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8986\u76d6---database\u6216-B\u9009\u9879\u3002\u9009\u9879\u540e\u9762\u7684\u6240\u6709\u53c2\u91cf\u88ab\u770b\u4f5c\u8868\u540d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --triggers<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4e3a\u6bcf\u4e2a\u8f6c\u50a8\u7684\u8868\u8f6c\u50a8\u89e6\u53d1\u5668\u3002\u8be5\u9009\u9879\u9ed8\u8ba4\u542f\u7528\uff1b\u7528--skip-triggers\u7981\u7528\u5b83\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --tz-utc<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5728\u8f6c\u50a8\u6587\u4ef6\u4e2d\u52a0\u5165SET TIME_ZONE='+00:00'\u4ee5\u4fbfTIMESTAMP\u5217\u53ef\u4ee5\u5728\u5177\u6709\u4e0d\u540c\u65f6\u533a\u7684\u670d\u52a1\u5668\u4e4b\u95f4\u8f6c\u50a8\u548c\u91cd\u8f7d\u3002(\u4e0d\u4f7f\u7528\u8be5\u9009\u9879\uff0cTIMESTAMP\u5217\u5728\u5177\u6709\u672c\u5730\u65f6\u533a\u7684\u6e90\u670d\u52a1\u5668\u548c\u76ee\u7684\u670d\u52a1\u5668\u4e4b\u95f4\u8f6c\u50a8\u548c\u91cd\u8f7d\uff09\u3002--tz-utc\u4e5f\u53ef\u4ee5\u4fdd\u62a4\u7531\u4e8e\u590f\u4ee4\u65f6\u5e26\u6765\u7684\u66f4\u6539\u3002--tz-utc\u9ed8\u8ba4\u542f\u7528\u3002\u8981\u60f3\u7981\u7528\u5b83\uff0c\u4f7f\u7528--skip-tz-utc\u3002\u8be5\u9009\u9879\u5728MySQL 5.1.2\u4e2d\u52a0\u5165\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --user=user_name\uff0c-u user_name<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8fde\u63a5\u670d\u52a1\u5668\u65f6\u4f7f\u7528\u7684MySQL\u7528\u6237\u540d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --verbose\uff0c-v<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5197\u957f\u6a21\u5f0f\u3002\u6253\u5370\u51fa\u7a0b\u5e8f\u64cd\u4f5c\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --version\uff0c-V<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u663e\u793a\u7248\u672c\u4fe1\u606f\u5e76\u9000\u51fa\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 --where='where-condition', -w 'where-condition'<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u53ea\u8f6c\u50a8\u7ed9\u5b9a\u7684WHERE\u6761\u4ef6\u9009\u62e9\u7684\u8bb0\u5f55\u3002\u8bf7\u6ce8\u610f\u5982\u679c\u6761\u4ef6\u5305\u542b\u547d\u4ee4\u89e3\u91ca\u7b26\u4e13\u7528\u7a7a\u683c\u6216\u5b57\u7b26\uff0c\u4e00\u5b9a\u8981\u5c06\u6761\u4ef6\u5f15\u7528\u8d77\u6765\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u4f8b\u5982\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \"--where=user='jimf'\" \"-wuserid&gt;1\" \"-wuserid&lt;1\" \u00b7 --xml\uff0c-X<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5c06\u8f6c\u50a8\u8f93\u51fa\u5199\u6210XML\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u8fd8\u53ef\u4ee5\u4f7f\u7528--var_name=value\u9009\u9879\u8bbe\u7f6e\u4e0b\u9762\u7684\u53d8\u91cf\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 max_allowed_packet<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5ba2\u6237\u7aef\/\u670d\u52a1\u5668\u4e4b\u95f4\u901a\u4fe1\u7684\u7f13\u5b58\u533a\u7684\u6700\u5927\u5927\u5c0f\u3002\u6700\u5927\u4e3a1GB\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u00b7 net_buffer_length<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"> \u5ba2\u6237\u7aef\/\u670d\u52a1\u5668\u4e4b\u95f4\u901a\u4fe1\u7684\u7f13\u5b58\u533a\u7684\u521d\u59cb\u5927\u5c0f\u3002\u5f53\u521b\u5efa\u591a\u884c\u63d2\u5165\u8bed\u53e5\u65f6(\u5982\u540c\u4f7f\u7528\u9009\u9879--extended-insert\u6216--opt)\uff0cmysqldump\u521b\u5efa\u957f\u5ea6\u8fbenet_buffer_length\u7684\u884c\u3002\u5982\u679c\u589e\u52a0\u8be5\u53d8\u91cf\uff0c\u8fd8\u5e94\u786e\u4fdd\u5728MySQL\u670d\u52a1\u5668\u4e2d\u7684net_buffer_length\u53d8\u91cf\u81f3\u5c11\u8fd9\u4e48\u5927<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><strong>5. \u57fa\u4e8e\u65f6\u95f4\u70b9\u7684\u6062\u590d<\/strong><\/span><\/p>\n<p>\u4f8b:<br \/>\n(1)\u4e0a\u534810\u70b9\u53d1\u751f\u8bef\u64cd\u4f5c,\u53ef\u4ee5\u7528\u5982\u4e0b\u8bed\u53e5\u5907\u4efd\u548cBINLOG\u5c06\u6570\u636e\u6062\u590d\u5230\u6545\u969c\u524d<br \/>\n#mysqlbinlog --stop-date=\"2010-10-31 9:59:59\" \/usr\/local\/mysql\/var\/mysql-bin.000013 |mysql -uroot -p<\/p>\n<p>(2)\u8df3\u8fc7\u6545\u969c\u65f6\u95f4\u70b9,\u7ee7\u7eed\u6267\u884c\u540e\u9762\u7684BINLOG,\u5b8c\u6210\u6062\u590d<br \/>\n#mysqlbinlog --start-date=\"2010-10-31 10:01:00\" \/usr\/local\/mysql\/var\/mysql-bin.000013 |mysql -uroot -p<\/p>\n<p>\u57fa\u4e8e\u4f4d\u7f6e\u6062\u590d(\u4e0d\u5b8c\u5168\u6062\u590d)<br \/>\n\u548c\u57fa\u4e8e\u65f6\u95f4\u70b9\u6062\u590d\u7c7b\u662f,\u4f46\u662f\u66f4\u52a0\u7cbe\u786e.\u56e0\u4e3a\u540c\u4e00\u65f6\u95f4\u70b9\u53ef\u80fd\u6709\u591a\u6761SQL\u8bed\u53e5\u6267\u884c;<br \/>\n\u4f8b:<br \/>\n#mysqlbinlog --start-date=\"2010-10-31 9:55:00\" --stop-date=\"2010-10-31 10:05:00\" \/usr\/local\/mysql\/var\/mysql-bin.000013 &gt; \/tmp\/mysql_restore.sql<\/p>\n<p>\u8be5\u547d\u4ee4\u5c06\u5728\/tmp\/\u76ee\u5f55\u4e0b\u521b\u5efa\u5c0f\u7684\u6587\u4ef6,\u7f16\u8f91\u5b83\u627e\u5230\u9519\u8bef\u8bed\u53e5\u524d\u540e\u7684\u4f4d\u7f6e\u53f7,\u4f8b\u5982\u524d\u540e\u4f4d\u7f6e\u53f7\u5206\u522b\u662f368312 \u548c 368315<br \/>\n(2)\u6062\u590d\u4e86\u4ee5\u524d\u7684\u5907\u4efd\u6587\u4ef6\u540e,\u8f93\u5165<br \/>\n#mysqlbinlog --stop-position=\"368312\" \/usr\/local\/mysql\/var\/mysql-bin.000013 |mysql -uroot -p<\/p>\n<p>#mysqlbinlog --start-position=\"368315\" \/usr\/local\/mysql\/var\/mysql-bin.000013 |mysql -uroot -p<\/p>\n<p><span style=\"font-size: 12pt;\"><b><br \/>\n7. \u53c2\u8003<\/b><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><a href=\"\/db\/587.html\" target=\"_blank\" rel=\"noopener noreferrer\">mysqldump error<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p><span style=\"font-size:14px;\">mysqldump \u7528\u6765\u8f6c\u50a8\u6570\u636e\u5e93\u6216\u641c\u96c6\u6570\u636e\u5e93\u8fdb\u884c\u5907\u4efd\u6216\u5c06\u6570\u636e\u8f6c\u5b58\u4e3a\u6587\u4ef6<\/span><br \/>\n<span style=\"font-size:14px;\"> \u5982\u5728\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u5907\u4efd\u5e76\u4e14\u8868\u5747\u4e3aMyISAM\u8868\uff0c\u5e94\u8003\u8651\u4f7f\u7528mysqlhotcopy\uff0c\u56e0\u4e3a\u53ef\u4ee5\u66f4\u5feb\u5730\u8fdb\u884c\u5907\u4efd\u548c\u6062\u590d\u3002<\/span><\/p>\n<p><b><span style=\"font-size:14px;\">1.mysqldump\u7684\u51e0\u79cd\u5e38\u7528\u65b9\u6cd5\uff1a<\/span><\/b><\/p>\n<p><span style=\"font-size:14px;\"> \uff081\uff09<\/span><b><span style=\"font-size:14px;\">\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93<\/span><\/b><span style=\"font-size:14px;\">(\u5305\u62ec\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size:14px;\"> &nbsp;&nbsp;&nbsp; mysqldump -u username -p dbname &gt; dbname.sql&nbsp;&nbsp; &nbsp;<\/span><\/p>\n<p><span style=\"font-size:14px;\"> \uff082\uff09<\/span><b><span style=\"font-size:14px;\">\u5bfc\u51fa\u6570\u636e\u5e93\u7ed3\u6784<\/span><\/b><span style=\"font-size:14px;\">\uff08\u4e0d\u542b\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size:14px;\"> &nbsp;&nbsp;&nbsp; mysqldump -u username -p -d dbname &gt; dbname.sql&nbsp;&nbsp; &nbsp;<\/span><\/p>\n<p><span style=\"font-size:14px;\"> \uff083\uff09<\/span><b><span style=\"font-size:14px;\">\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u67d0\u5f20\u6570\u636e\u8868<\/span><\/b><span style=\"font-size:14px;\">\uff08\u5305\u542b\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size:14px;\"> &nbsp;&nbsp;&nbsp; mysqldump -u username -p dbname tablename &gt; tablename.sql&nbsp;&nbsp; &nbsp;<\/span><\/p>\n<p><span style=\"font-size:14px;\"> \uff084\uff09<\/span><b><span style=\"font-size:14px;\">\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u67d0\u5f20\u6570\u636e\u8868\u7684\u8868\u7ed3\u6784<\/span><\/b><span style=\"font-size:14px;\">\uff08\u4e0d\u542b\u6570\u636e\uff09<\/span><\/p>\n<p><span style=\"font-size:14px;\"> &nbsp;&nbsp;&nbsp; mysqldump -u username -p -d dbname tablename &gt; tablename.sql &nbsp;<\/span><br \/>\n<span style=\"font-size:14px;\"> &nbsp;&nbsp; &nbsp;<\/span><br \/>\n<span style=\"font-size:14px;\"> \uff085\uff09<\/span><b><span style=\"font-size:14px;\">\u8f6c\u50a8\u51e0\u4e2a\u6570\u636e\u5e93<\/span><\/b><br \/>\n<span style=\"font-size:14px;\"> &nbsp;...<\/span> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/588\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[288],"tags":[2,270],"class_list":["post-588","post","type-post","status-publish","format-standard","hentry","category-db","tag-MySQL","tag-mysqldump"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=588"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/588\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}