{"id":386,"date":"2014-01-01T18:09:04","date_gmt":"2014-01-01T10:09:04","guid":{"rendered":"http:\/\/www.royalwzy.com\/?p=386"},"modified":"2015-09-02T07:33:33","modified_gmt":"2015-09-01T23:33:33","slug":"mysql%e5%ad%a6%e4%b9%a09-mysql5-1%e7%9a%84%e5%a4%87%e4%bb%bd%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"http:\/\/www.royalwzy.com\/?p=386","title":{"rendered":"MySQL\u5b66\u4e609&#8211;MySQL5.1\u7684\u5907\u4efd\u6062\u590d"},"content":{"rendered":"<div>\n<div>\u4f7f\u7528mysqldump\u5de5\u5177\u5907\u4efd<\/div>\n<ol>\n<li>mysql client is a backup program,it can be used to dump a database or a collection of databases for backup or for transferring the data to another SQL server(not necessarily a mysql server).The dump contains Sql statements to create the table or populate it, or both;<\/li>\n<li>\u5b83\u53ef\u4ee5\u5bfc\u51fa\u6240\u6709\u7684\u6570\u636e\u5e93,\u6307\u5b9a\u7684\u4e00\u4e2a\u6216\u8005\u51e0\u4e2a\u6570\u636e\u5e93,\u6216\u8005\u4e00\u5f20\u8868;<\/li>\n<li>mysqldump\u53ef\u4ee5\u5907\u4efd\u672c\u5730\u7684\u6216\u8005\u8fdc\u7a0b\u7684\u670d\u52a1\u5668,\u5bfc\u51fa\u7684\u6587\u4ef6\u5305\u542bCREATE TABLE\u548cINSERT\u8bed\u53e5\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u8868,\u670d\u52a1\u5668\u53d1\u9001\u8868\u5185\u5bb9\u5230mysqldump\u7a0b\u5e8f,\u5b83\u628a\u6587\u4ef6\u5199\u5230\u5ba2\u6237\u7aef;<\/li>\n<li>\u5b83\u53ef\u4ee5\u5907\u4efd\u5404\u79cd\u5f15\u64ce\u7684\u8868;<\/li>\n<li>\u5bfc\u51fa\u7684\u6587\u4ef6\u662f\u6587\u672c\u6587\u4ef6,\u6240\u4ee5\u6709\u5f88\u5f3a\u7684\u7075\u6d3b\u6027,\u53ef\u4ee5\u88ab\u7528\u4e8e\u5728\u4e0d\u540c\u7684\u670d\u52a1\u5668\u4e0a;<\/li>\n<\/ol>\n<div><\/div>\n<div>mysqldump\u7684\u53c2\u6570<\/div>\n<ol>\n<li>-A,&#8211;all-databases:\u5bfc\u51fa\u6240\u6709\u7684\u6570\u636e\u5e93,\u8ddf\u4f7f\u7528&#8211;databases\u540e\u9762\u8ddf\u4e0a\u6240\u6709\u7684\u6570\u636e\u5e93\u662f\u4e00\u6837\u7684;<\/li>\n<li><span style=\"color: #e30000;\">&#8211;add-drop-database:<\/span>\u5728\u521b\u5efa\u6570\u636e\u5e93\u524d\u6dfb\u52a0drop database\u7684\u8bed\u53e5;<\/li>\n<li><span style=\"color: #e30000;\">&#8211;add-drop-table:<\/span>\u5728\u521b\u5efa\u8868\u4e4b\u524d\u6dfb\u52a0drop table\u8bed\u53e5;<\/li>\n<li>&#8211;add-locks:\u5728\u63d2\u5165\u8bed\u53e5\u524d\u52a0\u9501;<\/li>\n<li>&#8211;allow-keywords:\u521b\u5efa\u7684\u5217\u5141\u8bb8\u4f7f\u7528\u5173\u952e\u5b57;<\/li>\n<li>-i,&#8211;comments:\u5199\u5165\u9644\u52a0\u4fe1\u606f,\u5373\u6dfb\u52a0\u6ce8\u91ca;<\/li>\n<li>-c,&#8211;complete-insert:\u4f7f\u7528\u5b8c\u5168\u63d2\u5165\u8bed\u53e5,\u4e2a\u4eba\u89c9\u5f97\u8fd8\u662f-e\u53c2\u6570\u597d,\u6570\u636e\u91cf\u5c0f\u7528-e,\u6570\u636e\u91cf\u5927\u7528-c;<\/li>\n<li><span style=\"color: #e30000;\">-B,&#8211;databases:<\/span>\u5907\u4efd\u591a\u4e2a\u6570\u636e\u5e93,\u628a\u8981\u5907\u4efd\u7684\u6570\u636e\u5e93\u8ddf\u5728\u53c2\u6570\u540e\u9762\u5373\u53ef,\u5f53\u524d\u6570\u636e\u5e93\u4e5f\u4f1a\u88ab\u5305\u6db5\u8fdb\u6765;<\/li>\n<li>&#8211;delete-master-logs:\u5907\u4efd\u5b8c\u6210\u540e\u5220\u9664\u4e3b\u673a\u65e5\u5fd7,\u81ea\u52a8\u6253\u5f00&#8211;master-data\u9009\u9879;<\/li>\n<li><span style=\"color: #e30000;\">-e,&#8211;extended-insert:<\/span>\u4f7f\u7528multiple-row INSERT\u8bed\u53e5,\u5373\u4e00\u4e2ainsert\u8bed\u53e5\u540e\u9762\u6709\u591a\u4e2a\u503c\u7684\u5217\u8868,\u8fd9\u662f\u4e00\u79cd\u66f4\u9ad8\u6548\u7684\u63d2\u5165\u65b9\u5f0f;<\/li>\n<li><span style=\"color: #e30000;\">-F,&#8211;flush-logs:<\/span>\u5f00\u59cb\u5907\u4efd\u524d\u5207\u6362\u4e00\u4e0b\u65e5\u5fd7,\u5982\u679c\u4f60\u4e00\u6b21\u5907\u4efd\u591a\u4e2a\u6570\u636e\u5e93(\u4f7f\u7528&#8211;databases\u6216\u8005&#8211;all-databases\u9009\u9879\u65f6),\u5219\u5728\u5907\u4efd\u6bcf\u4e2a\u6570\u636e\u5e93\u524d\u90fd\u4f1a\u5207\u6362\u65e5\u5fd7.\u5f53\u4f7f\u7528&#8211;lock-all-tables or &#8211;master-data\u65f6,\u65e5\u5fd7\u53ea\u4f1a\u88ab\u5207\u6362\u4e00\u6b21,\u56e0\u4e3a\u6b64\u65f6\u6240\u6709\u7684\u8868\u90fd\u88ab\u9501\u4f4f,\u6570\u636e\u5e93\u4fdd\u6301\u4e00\u81f4.\u6240\u4ee5\u5f53\u4f60\u60f3\u8981\u5907\u4efd\u548c\u65e5\u5fd7\u7ec4\u5207\u6362\u540c\u65f6\u53d1\u751f\u65f6,\u8981\u7528&#8211;lock-all-tables or &#8211;master-data\u548c&#8211;flush-logs\u4e00\u8d77\u4f7f\u7528;<\/li>\n<li>-h,&#8211;host=name:\u8fde\u63a5\u5230\u4e3b\u673a;-u,&#8211;user-name:\u7528\u6237\u540d;-p,&#8211;password:\u7528\u6237\u5bc6\u7801;<\/li>\n<li><span style=\"color: #ff0000;\">&#8211;ignore-table=name:<\/span>\u4e0d\u5907\u4efd\u6307\u5b9a\u7684\u8868,\u5982\u679c\u8981\u6307\u5b9a\u591a\u4e2a\u8868,\u5219\u8981\u6570\u636e\u5e93\u548c\u8868\u660e\u4e00\u8d77\u6307\u5b9a,\u5982:&#8211;ignore-table=database.table;<\/li>\n<li><span style=\"color: #e30000;\">-x,&#8211;lock-all-tables:<\/span>\u4f1a\u9501\u4f4f\u6240\u6709\u6570\u636e\u5e93\u7684\u8868,\u4f1a\u5728\u5907\u4efd\u671f\u95f4\u52a0\u5168\u5c40\u53ea\u8bfb\u9501,\u81ea\u52a8\u5173\u95ed&#8211;single-transaction\u548c&#8211;lock-tables\u9009\u9879;<\/li>\n<li><span style=\"color: #e30000;\">&#8211;master-data[=#]:<\/span>\u4f7f\u5f97\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u4f4d\u7f6e\u548c\u548c\u540d\u79f0\u88ab\u6dfb\u52a0\u5230\u8f93\u51fa\u6587\u4ef6\u4e2d,\u5982\u679c\u7b49\u4e8e1,\u4f1a\u50cfCHANGE MASTER\u547d\u4ee4\u4e00\u6837\u6253\u5370\u5b83,\u5982\u679c\u7b49\u4e8e2,\u547d\u4ee4\u4f1a\u4ee5\u6ce8\u91ca\u7684\u5f62\u5f0f\u51fa\u73b0.\u8fd9\u4e2a\u9009\u9879\u4f1a\u6253\u5f00&#8211;lock-all-table\u9009\u9879,\u9664\u975e&#8211;single-transaction\u9009\u9879\u4e5f\u88ab\u6307\u5b9a(\u6b64\u65f6\u5168\u5c40\u53ea\u8bfb\u9501\u77e5\u4f1a\u5728\u5f00\u59cb\u5907\u4efd\u65f6\u6709\u6548),\u53ef\u4ee5\u901a\u8fc7s<span style=\"color: #e30000;\">how master status\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u65e5\u5fd7\u4fe1\u606f,\u5728\u6062\u590d\u548c\u590d\u5236\u529f\u80fd\u65f6\u6709\u7528<\/span>.<\/li>\n<li><span style=\"color: #e30000;\">-n,&#8211;no-create-db:<\/span>\u4e0d\u5305\u62ec\u521b\u5efa\u6570\u636e\u5e93\u7684\u8bed\u53e5;<\/li>\n<li><span style=\"color: #e30000;\">-t,&#8211;no-create-info<\/span>:\u4e0d\u5305\u62ec\u521b\u5efa\u8868\u7ed3\u6784\u8bed\u53e5;<\/li>\n<li><span style=\"color: #e30000;\"><b>-d,&#8211;no-data:\u53ea\u5305\u542b\u8868\u5b9a\u4e49,\u4e0d\u5305\u542b\u8868\u6570\u636e;<\/b><\/span><\/li>\n<li><span style=\"color: #e30000;\">&#8211;order-by-primary:<\/span>\u4f7f\u6bcf\u4e2a\u8868\u4e2d\u7684\u8bb0\u5f55\u6309\u7167\u4e3b\u952e\u6392\u5e8f,\u5982\u679c\u6ca1\u6709\u4e3b\u952e,\u5219\u4f7f\u7528\u7b2c\u4e00\u4e2a\u552f\u4e00\u7d22\u5f15.\u5f53\u5bfc\u51fa\u4e00\u4e2aMyISAM\u8868\u5230\u4e00\u4e2aInnoDB\u8868\u65f6\u6709\u7528,\u4f46\u662f\u4f1a\u5ef6\u957f\u5bfc\u51fa\u65f6\u95f4;<\/li>\n<li><span style=\"color: #e30000;\">&#8211;quick:<\/span>\u4e0d\u7f13\u5b58query,\u76f4\u63a5\u5bfc\u51fa\u5230\u6807\u51c6\u8f93\u51fa;<\/li>\n<li><b><span style=\"color: #e30000;\">-R,&#8211;routines:\u5bfc\u51fastored routines(\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570);<\/span><\/b><\/li>\n<li>&#8211;single-transaction:\u5728\u4e00\u4e2a\u4e8b\u52a1\u4e2d\u521b\u5efa\u4e00\u4e2a\u4e00\u81f4\u6027\u7684\u5feb\u7167,\u53ea\u5728\u652f\u6301\u591a\u7248\u672c\u63a7\u5236\u7684\u5f15\u64ce\u4e2d\u8d77\u4f5c\u7528,\u76ee\u524d\u53ea\u6709innodb\u5f15\u64ce.\u5f53&#8211;single-transaction\u8fdb\u7a0b\u5de5\u4f5c\u65f6,\u4e3a\u4e86\u4fdd\u6301\u6570\u636e\u4e00\u81f4\u6027,\u5219\u4e0d\u80fd\u4f7f\u7528ALTER TABLE,DROP TABLE,RENAME TABLE,TRUNCATE TABLEY\u8bed\u53e5,\u6b64\u9009\u9879\u81ea\u52a8\u5173\u95ed&#8211;lock-tables\u9009\u9879;<\/li>\n<li>&#8211;opt:\u4e0e\u540c\u65f6\u6307\u5b9a&#8211;add-drop-table, &#8211;add-locks, &#8211;create-options,\u00a0&#8211;quick, &#8211;extended-insert, &#8211;lock-tables, &#8211;set-charset,\u00a0and &#8211;disable-keys\u76f8\u540c.\u9ed8\u8ba4\u5f00\u542f,\u8981\u5173\u95ed\u4f7f\u7528&#8211;skip-opt;<\/li>\n<li><span style=\"color: #e30000;\">-w,&#8211;where=name<\/span>:\u53ea\u5bfc\u51fa\u9009\u62e9\u7684\u8bb0\u5f55;<\/li>\n<\/ol>\n<div><\/div>\n<div>\u5982\u4f55\u4f7f\u7528mysqldump\u5907\u4efd<\/div>\n<ol>\n<li>\u975e\u4e8b\u52a1\u8868\u7684\u4e00\u81f4\u5907\u4efd:mysqldump\u00a0&#8211;opt\u00a0<span style=\"color: #e30000;\">&#8211;lock-all-tables<\/span>\u00a0&#8211;master-data=2 -B db_name1 db_name2 &gt; \/tmp\/backup.sql,\u5907\u4efd\u65f6\u8868\u662f\u53ea\u8bfb\u7684;<\/li>\n<li>\u4e8b\u52a1\u8868\u7684\u4e00\u81f4\u5907\u4efd:mysqldump &#8211;opt\u00a0<span style=\"color: #e30000;\">&#8211;single-transaction<\/span>\u00a0&#8211;master-data=2 -B db_name1 db_name2 &gt; \/tmp\/backup.sql,\u5907\u4efd\u65f6\u8868\u662f\u53ef\u8bfb\u5199\u7684;<\/li>\n<\/ol>\n<div><\/div>\n<div>mysqlbinlog\u5de5\u5177<\/div>\n<ol>\n<li>\u670d\u52a1\u5668\u751f\u6210\u7684binary log files\u662f\u4e8c\u8fdb\u5236\u6587\u4ef6,\u60f3\u8981\u67e5\u770b\u8fd9\u4e9b\u6587\u4ef6,\u5fc5\u987b\u4f7f\u7528mysqlbinlog\u5de5\u5177.\u8fd8\u53ef\u4ee5\u4f7f\u7528mysqlbinlog\u5de5\u5177\u8bfb\u53d6\u590d\u5236\u529f\u80fdslave\u670d\u52a1\u5668\u4ea7\u751f\u7684relay log files,\u5b83\u548c\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6709\u76f8\u540c\u7684\u7ed3\u6784;<\/li>\n<li>\u7528\u6cd5:mysqlbinlog [options] log-files;<\/li>\n<\/ol>\n<div><\/div>\n<div>mysqlbinlog\u7684\u53c2\u6570<\/div>\n<ol>\n<li>-d,&#8211;database=name:\u5217\u51fa\u67d0\u4e00\u4e2a\u6570\u636e\u5e93\u7684\u65e5\u5fd7,\u53ea\u7528\u4e8e\u672c\u5730\u65e5\u5fd7;<\/li>\n<li>-f,&#8211;force-read:\u5982\u679cmysqlbinlog\u8bfb\u5230\u5b83\u4e0d\u80fd\u8bc6\u522b\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7,\u4f1a\u6253\u5370\u8b66\u544a\u800c\u5ffd\u7565\u8be5\u4e8b\u4ef6\u5e76\u7ee7\u7eed,\u5982\u679c\u6ca1\u6709\u8be5\u4e8b\u4ef6\u5219\u505c\u6b62;<\/li>\n<li>-o,&#8211;offset=#\uff1a\u5ffd\u7565\u524dN\u4e2a\u5b9e\u4f53;<\/li>\n<li><span style=\"color: #e30000;\">-R,&#8211;read-from-remote-server:<\/span>\u4ece\u8fdc\u7a0b\u670d\u52a1\u5668\u8bfb\u53d6\u4e8c\u8fdb\u5236\u65e5\u5fd7,\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u6b64\u9009\u9879,\u5219&#8211;host, &#8211;user, &#8211;password, &#8211;port, &#8211;protocal, &#8211;socket\u9009\u9879\u90fd\u88ab\u5ffd\u7565;<\/li>\n<li>-r,&#8211;result-file=name:\u76f4\u63a5\u8f93\u51fa\u5230\u7ed9\u5b9a\u7684\u6587\u4ef6;<\/li>\n<li><span style=\"color: #e30000;\">&#8211;start-datetime=time:<\/span>\u8bfb\u53d6\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u751f\u6210\u5f00\u59cb\u65f6\u95f4,\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55mysql\u670d\u52a1\u5668\u7684\u65f6\u95f4\u683c\u5f0f,datetime\u548ctimestamp\u7c7b\u578b,\u5982:&#8217;YYYY-MM-DD HH24:MI:SS&#8217;;<\/li>\n<li><span style=\"color: #ff0000;\">&#8211;stop-datetime=time:<\/span>\u8bfb\u53d6\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u751f\u6210\u7ed3\u675f\u65f6\u95f4;<\/li>\n<li><span style=\"color: #e30000;\">-j,&#8211;start-position=#<\/span>:\u8bfb\u53d6\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u751f\u6210\u5f00\u59cb\u4f4d\u7f6e,\u662f\u4e00\u4e2a\u6574\u578b\u53c2\u6570;<\/li>\n<li><span style=\"color: #e30000;\">&#8211;stop-position=#:<\/span>\u8bfb\u53d6\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u751f\u6210\u7ed3\u675f\u4f4d\u7f6e,\u4e00\u4e2a\u6574\u578b\u53c2\u6570;<\/li>\n<li>-t,&#8211;to-last-log:\u5728mysql\u670d\u52a1\u5668\u4e2d\u8bf7\u6c42\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7ed3\u5c3e\u5904\u4e0d\u505c\u6b62,\u800c\u662f\u7ee7\u7eed\u6253\u5370\u76f4\u5230\u6700\u540e\u4e00\u4e2a\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u7ed3\u5c3e,\u5982\u679c\u5c06\u8f93\u51fa\u53d1\u9001\u7ed9\u540c\u4e00\u53f0mysql\u670d\u52a1\u5668,\u4f1a\u5bfc\u5bfc\u81f4\u65e0\u9650\u5faa\u73af,\u8981\u4e0e&#8211;read-from-remote-server\u8fde\u7528;<\/li>\n<li>-D,&#8211;disable-log-bin:\u7981\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7,\u5982\u679c\u4f7f\u7528&#8211;to-last-logs\u9009\u9879\u5c06\u8f93\u51fa\u53d1\u9001\u7ed9\u540c\u4e00\u53f0mysql\u670d\u52a1\u5668,\u53ef\u4ee5\u907f\u514d\u65e0\u9650\u5faa\u73af,\u8be5\u9009\u9879\u5728\u5d29\u6e83\u6062\u590d\u4e5f\u5f88\u6709\u7528,\u53ef\u4ee5\u907f\u514d\u590d\u5236\u5df2\u7ecf\u8bb0\u5f55\u7684\u8bed\u53e5;<\/li>\n<\/ol>\n<div><\/div>\n<div>binlog\u89e3\u8bfb<\/div>\n<ol>\n<li>\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\u7684\u65b9\u5f0f\u4e0ebinlog_format\u53c2\u6570\u6709\u5173;<\/li>\n<li>\u67e5\u770bbinlog\u7684\u8bed\u6cd5:? binlog;<\/li>\n<li>\u8bb0\u5f55\u7684\u5185\u5bb9\u6709:\u65f6\u95f4\u6233, \u4e3b\u673aserver id, \u65f6\u95f4\u7ed3\u675f\u4f4d\u7f6e, \u65f6\u95f4\u5bf9\u8c61, \u65f6\u95f4\u6807\u5fd7\u4f4d, \u5185\u90e8binlog\u547d\u4ee4\u548c\u76f8\u5173\u6ce8\u91ca;<\/li>\n<\/ol>\n<div><\/div>\n<div>mysql\u6570\u636e\u5e93\u7684\u5907\u4efd\u4e0e\u6062\u590d<\/div>\n<ol>\n<li><span style=\"color: #e30000;\">\u53ea\u5907\u4efdroutines(\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570,-R\u53c2\u6570,\u5728information_schema.routines\u8868\u4e2d)\u548cevents(\u4f5c\u4e1a,-E\u53c2\u6570,\u5728information_schema.events\u8868\u4e2d)\u4fe1\u606f:mysqldump -n\u00a0-t\u00a0-d -R -E &gt; \/tmp\/routines.sql;<\/span><\/li>\n<li><span style=\"color: #e30000;\">\u5907\u4efd\u8868\u7ed3\u6784,\u89c6\u56fe,\u51fd\u6570,\u5b58\u50a8\u8fc7\u7a0b\u548c\u4f5c\u4e1a\u7684\u4fe1\u606f:<\/span>mysqldump -d -R -E -S \/mysql\/logs\/mysqld.sock &#8211;databases db_name &gt; \/tmp\/objects.sql;<\/li>\n<li>\u5907\u4efd\u6570\u636e\u5e93test,\u5305\u62ec\u89c6\u56fe\u4fe1\u606f:mysqldump\u00a0&#8211;opt\u00a0<span style=\"color: #e30000;\">&#8211;lock-all-tables<\/span>\u00a0-R -E\u00a0&#8211;master-data=2 -B test &gt; \/tmp\/test_backup.sql;(\u67e5\u770b\u5f53\u524d\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u540d\u79f0\u548c\u4f4d\u7f6e:show master logs;); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(264).png\" width=\"818\" height=\"44\" \/><\/li>\n<li>\u5bf9\u8868\u8fdb\u884c\u4fee\u6539,\u7136\u540e\u5220\u9664:\n<ol>\n<li>insert into t values(1, now());<\/li>\n<li>insert into t values(2, now());<\/li>\n<li>insert into t values(3, now());<\/li>\n<li>drop table t;<\/li>\n<\/ol>\n<\/li>\n<li>\u67e5\u770b\u8868\u5220\u9664\u7684\u4f4d\u7f6e:mysql&gt;show binlog events;\u5982\u679c\u8981\u67e5\u8be2\u67d0\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u4f7f\u7528:show binlog events in &#8216;binlog file name&#8217;; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(265).png\" width=\"827\" height=\"375\" \/><\/li>\n<li>\u67e5\u770b\u8868\u5907\u4efd\u6587\u4ef6\u7684\u4f4d\u7f6e:grep &#8220;CHANGE MASTER&#8221; \/tmp\/test_backup.sql; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(266).png\" width=\"696\" height=\"42\" \/><\/li>\n<li>\u8fd8\u539f\u6570\u636e\u5e93:mysql &lt; \/tmp\/test_backup.sql;\u76f4\u63a5\u6267\u884c\u5907\u4efd\u7684\u811a\u672c\u6587\u4ef6,\u8fd8\u539f\u5230\u5907\u4efd\u7684\u72b6\u6001;<\/li>\n<li>\u6062\u590d\u6570\u636e\u5e93(\u6ce8\u610fmysqlbinlog\u7684\u7248\u672c,\u5e94\u8be5\u4f7f\u7528mysql basedir\u4e0b\u7684mysqlbinlog):mysqlbinlog &#8211;start-position=117 &#8211;stop-position=480 \/path\/mysql-bin.000001 | mysql; \u53ef\u4ee5\u4f7f\u7528&#8211;disable-log-bin:\u7981\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(267).png\" width=\"824\" height=\"39\" \/><\/li>\n<li>\u5efa\u8bae\u628a\u5907\u4efd\u7684\u6570\u636e\u5e93\u6062\u590d\u5230\u6d4b\u8bd5\u670d\u52a1\u5668,\u7136\u540e\u628a\u6570\u636e\u5bfc\u5165\u5230\u751f\u4ea7\u73af\u5883;<\/li>\n<\/ol>\n<div><\/div>\n<div>\u8868\u7ed3\u6784\u7684\u590d\u5236<\/div>\n<div>\n<ol>\n<li>\u7b2c\u4e00\u79cd\u505a\u6cd5\u662f:CREATE TABLE table_name AS SELECT * FROM tb_name;\n<ol>\n<li>\u53ef\u4ee5\u590d\u5236\u8868\u63a5\u53e3\u548c\u8868\u4e2d\u6570\u636e,\u5982\u679c\u53ea\u60f3\u8981\u8868\u63a5\u53e3\u53ef\u4ee5\u52a0\u4e00\u4e2afalse\u7684\u8fc7\u6ee4;<\/li>\n<li>\u4f46\u662f\u4f1a\u4e22\u5931\u8868\u4e2d\u5217\u4e0a\u9762\u7684\u5c5e\u6027(\u5982\u81ea\u589e\u5c5e\u6027)\u548c\u7d22\u5f15(\u4e3b\u5916\u952e);<\/li>\n<\/ol>\n<\/li>\n<li>\u7b2c\u4e8c\u79cd\u505a\u6cd5\u662f:CREATE TABLE table_name(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY) SELECT * FROM table_name;\n<ol>\n<li>\u53ef\u4ee5\u5728\u521b\u5efa\u8868\u65f6\u6307\u5b9a\u6240\u6709\u7684\u5c5e\u6027,\u5e76\u540c\u6b65\u6570\u636e;<\/li>\n<li>\u4f46\u662f\u8bed\u6cd5\u592a\u9ebb\u70e6;<\/li>\n<\/ol>\n<\/li>\n<li>\u7b2c\u4e09\u79cd\u505a\u6cd5\u662f:CREATE TABLE table_name LIKE table_name;\n<ol>\n<li>\u53ea\u590d\u5236\u8868\u7ed3\u6784,\u800c\u4e14\u4fdd\u7559\u5217\u7684\u5c5e\u6027\u548c\u7d22\u5f15;<\/li>\n<li>\u5982\u679c\u60f3\u8981\u6570\u636e\u7684\u8bdd\u53ef\u4ee5INSERT table_name SELECT * FROM table_name;<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528mysqldump\u5de5\u5177\u5907\u4efd mysql client is a backup program,it can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[27],"class_list":["post-386","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=386"}],"version-history":[{"count":0,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/386\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=386"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}