{"id":1301,"date":"2015-07-30T17:32:49","date_gmt":"2015-07-30T09:32:49","guid":{"rendered":"http:\/\/www.strongd.net\/?p=1301"},"modified":"2015-07-30T17:34:12","modified_gmt":"2015-07-30T09:34:12","slug":"%e5%a6%82%e4%bd%95%e5%af%bc%e5%85%a5%e5%af%bc%e5%87%bamysql%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=1301","title":{"rendered":"\u5982\u4f55\u5bfc\u5165\u5bfc\u51faMySQL\u6570\u636e\u5e93"},"content":{"rendered":"<p>1. \u6982\u8ff0 MySQL\u6570\u636e\u5e93\u7684\u5bfc\u5165\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a<br \/>\n1) \u5148\u5bfc\u51fa\u6570\u636e\u5e93SQL\u811a\u672c\uff0c\u518d\u5bfc\u5165\uff1b<br \/>\n2) \u76f4\u63a5\u62f7\u8d1d\u6570\u636e\u5e93\u76ee\u5f55\u548c\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u6216MySQL\u7248\u672c\u60c5\u51b5\u4e0b\uff0c\u76f4\u63a5\u62f7\u8d1d\u6587\u4ef6\u7684\u65b9\u6cd5\u53ef\u80fd\u4f1a\u6709\u4e0d\u517c\u5bb9\u7684\u60c5\u51b5\u53d1\u751f\u3002<br \/>\n\u6240\u4ee5\u4e00\u822c\u63a8\u8350\u7528SQL\u811a\u672c\u5f62\u5f0f\u5bfc\u5165\u3002<\/p>\n<p>\u4e0b\u9762\u5206\u522b\u4ecb\u7ecd\u4e24\u79cd\u65b9\u6cd5\u3002<br \/>\n2. \u65b9\u6cd5\u4e00 SQL\u811a\u672c\u5f62\u5f0f \u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\uff1a<br \/>\n2.1. \u5bfc\u51faSQL\u811a\u672c \u5728\u539f\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\uff0c\u53ef\u4ee5\u7528phpMyAdmin\u5de5\u5177\uff0c\u6216\u8005mysqldump(mysqldump\u547d\u4ee4\u4f4d\u4e8emysql\/bin\/\u76ee\u5f55\u4e2d)\u547d\u4ee4\u884c\uff0c\u5bfc\u51faSQL\u811a\u672c\u3002<br \/>\n2.1.1 \u7528phpMyAdmin\u5de5\u5177 \u5bfc\u51fa\u9009\u9879\u4e2d\uff0c\u9009\u62e9\u5bfc\u51fa\u201c\u7ed3\u6784\u201d\u548c\u201c\u6570\u636e\u201d\uff0c\u4e0d\u8981\u6dfb\u52a0\u201cDrop DATABASE\u201d\u548c\u201cDrop TABLE\u201d\u9009\u9879\u3002<br \/>\n\u9009\u4e2d\u201c\u53e6\u5b58\u4e3a\u6587\u4ef6\u201d\u9009\u9879\uff0c\u5982\u679c\u6570\u636e\u6bd4\u8f83\u591a\uff0c\u53ef\u4ee5\u9009\u4e2d\u201cgzipped\u201d\u9009\u9879\u3002 \u5c06\u5bfc\u51fa\u7684SQL\u6587\u4ef6\u4fdd\u5b58\u4e0b\u6765\u3002<\/p>\n<p>2.1.2 \u7528mysqldump\u547d\u4ee4\u884c \u547d\u4ee4\u683c\u5f0f<br \/>\nmysqldump -u\u7528\u6237\u540d -p \u6570\u636e\u5e93\u540d &gt; \u6570\u636e\u5e93\u540d.sql<br \/>\n\u8303\u4f8b\uff1a mysqldump -uroot -p abc &gt; abc.sql \uff08\u5bfc\u51fa\u6570\u636e\u5e93abc\u5230abc.sql\u6587\u4ef6\uff09<br \/>\n\u63d0\u793a\u8f93\u5165\u5bc6\u7801\u65f6\uff0c\u8f93\u5165\u8be5\u6570\u636e\u5e93\u7528\u6237\u540d\u7684\u5bc6\u7801\u3002<\/p>\n<p>2.2. \u521b\u5efa\u7a7a\u7684\u6570\u636e\u5e93 \u901a\u8fc7\u4e3b\u63a7\u754c\u9762\/\u63a7\u5236\u9762\u677f\uff0c\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u3002\u5047\u8bbe\u6570\u636e\u5e93\u540d\u4e3aabc\uff0c\u6570\u636e\u5e93\u5168\u6743\u7528\u6237\u4e3aabc_f\u3002<\/p>\n<p>2.3. \u5c06SQL\u811a\u672c\u5bfc\u5165\u6267\u884c \u540c\u6837\u662f\u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u7528phpMyAdmin\uff08mysql\u6570\u636e\u5e93\u7ba1\u7406\uff09\u5de5\u5177\uff0c\u6216\u8005mysql\u547d\u4ee4\u884c\u3002<br \/>\n2.3.1 \u7528phpMyAdmin\u5de5\u5177 \u4ece\u63a7\u5236\u9762\u677f\uff0c\u9009\u62e9\u521b\u5efa\u7684\u7a7a\u6570\u636e\u5e93\uff0c\u70b9\u201c\u7ba1\u7406\u201d\uff0c\u8fdb\u5165\u7ba1\u7406\u5de5\u5177\u9875\u9762\u3002 \u5728&#8221;SQL&#8221;\u83dc\u5355\u4e2d\uff0c\u6d4f\u89c8\u9009\u62e9\u521a\u624d\u5bfc\u51fa\u7684SQL\u6587\u4ef6\uff0c\u70b9\u51fb\u201c\u6267\u884c\u201d\u4ee5\u4e0a\u8f7d\u5e76\u6267\u884c\u3002 \u6ce8\u610f\uff1aphpMyAdmin\u5bf9\u4e0a\u8f7d\u7684\u6587\u4ef6\u5927\u5c0f\u6709\u9650\u5236\uff0cphp\u672c\u8eab\u5bf9\u4e0a\u8f7d\u6587\u4ef6\u5927\u5c0f\u4e5f\u6709\u9650\u5236\uff0c\u5982\u679c\u539f\u59cbsql\u6587\u4ef6 \u6bd4\u8f83\u5927\uff0c\u53ef\u4ee5\u5148\u7528gzip\u5bf9\u5b83\u8fdb\u884c\u538b\u7f29\uff0c\u5bf9\u4e8esql\u6587\u4ef6\u8fd9\u6837\u7684\u6587\u672c\u6587\u4ef6\uff0c\u53ef\u83b7\u5f971:5\u6216\u66f4\u9ad8\u7684\u538b\u7f29\u7387\u3002<br \/>\ngzip\u4f7f\u7528\u65b9\u6cd5\uff1a # gzip xxxxx.sql \u5f97\u5230 xxxxx.sql.gz\u6587\u4ef6\u3002<\/p>\n<p>2.3.2 \u7528mysql\u547d\u4ee4\u884c<br \/>\n\u547d\u4ee4\u683c\u5f0f mysql -u\u7528\u6237\u540d -p \u6570\u636e\u5e93\u540d &lt; \u6570\u636e\u5e93\u540d.sql<\/p>\n<p>\u8303\u4f8b\uff1a mysql -uabc_f -p abc &lt; abc.sql \uff08\u5bfc\u5165\u6570\u636e\u5e93abc\u4eceabc.sql\u6587\u4ef6\uff09<br \/>\n\u63d0\u793a\u8f93\u5165\u5bc6\u7801\u65f6\uff0c\u8f93\u5165\u8be5\u6570\u636e\u5e93\u7528\u6237\u540d\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u65b9\u6cd52\u8fdb\u5165mysql\uff0c\u5efa\u7acb\u6570\u636e\u5e93\uff0c\u9009\u62e9\u6570\u636e\u5e93\u540e\uff0c\u6253\u5165\u4e0b\u9762\u4ee3\u7801\uff0cd:\\112121.sql\u4e3a\u6570\u636e\u5e93\u76ee\u5f55\u3002<\/p>\n<p>mysql&gt;source d:\\112121.sql<br \/>\n3 \u65b9\u6cd5\u4e8c \u76f4\u63a5\u62f7\u8d1d \u5982\u679c\u6570\u636e\u5e93\u6bd4\u8f83\u5927\uff0c\u53ef\u4ee5\u8003\u8651\u7528\u76f4\u63a5\u62f7\u8d1d\u7684\u65b9\u6cd5\uff0c\u4f46\u4e0d\u540c\u7248\u672c\u548c\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u95f4\u53ef\u80fd\u4e0d\u517c\u5bb9\uff0c\u8981\u614e\u7528\u3002<br \/>\n3.1 \u51c6\u5907\u539f\u59cb\u6587\u4ef6<br \/>\n\u7528tar\u6253\u5305\u4e3a\u4e00\u4e2a\u6587\u4ef6<br \/>\n3.2 \u521b\u5efa\u7a7a\u6570\u636e\u5e93<br \/>\n3.3 \u89e3\u538b<br \/>\n\u5728\u4e34\u65f6\u76ee\u5f55\u4e2d\u89e3\u538b\uff0c\u5982\uff1a cd \/tmp tar zxf mydb.tar.gz<br \/>\n3.4 \u62f7\u8d1d<br \/>\n\u5c06\u89e3\u538b\u540e\u7684\u6570\u636e\u5e93\u6587\u4ef6\u62f7\u8d1d\u5230\u76f8\u5173\u76ee\u5f55 cd mydb\/ cp * \/var\/lib\/mysql\/mydb\/ \u5bf9\u4e8eFreeBSD: cp * \/var\/db\/mysql\/mydb\/<br \/>\n3.5 \u6743\u9650\u8bbe\u7f6e<\/p>\n<p>\u5c06\u62f7\u8d1d\u8fc7\u53bb\u7684\u6587\u4ef6\u7684\u5c5e\u4e3b\u6539\u4e3amysql:mysql\uff0c<\/p>\n<p>\u6743\u9650\u6539\u4e3a660<\/p>\n<p>&nbsp;<\/p>\n<p>chown mysql:mysql \/var\/lib\/mysql\/mydb\/*<\/p>\n<p>chmod 660 \/var\/lib\/mysql\/mydb\/*<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u6982\u8ff0 MySQL\u6570\u636e\u5e93\u7684\u5bfc\u5165\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a 1) \u5148\u5bfc\u51fa\u6570\u636e\u5e93SQL\u811a\u672c\uff0c\u518d\u5bfc\u5165\uff1b 2) \u76f4\u63a5\u62f7\u8d1d\u6570\u636e\u5e93\u76ee\u5f55\u548c\u6587\u4ef6\u3002 \u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u6216MySQL\u7248\u672c\u60c5\u51b5\u4e0b\uff0c\u76f4\u63a5\u62f7\u8d1d\u6587\u4ef6\u7684\u65b9\u6cd5\u53ef\u80fd\u4f1a\u6709\u4e0d\u517c\u5bb9\u7684\u60c5\u51b5\u53d1\u751f\u3002 \u6240\u4ee5\u4e00\u822c\u63a8\u8350\u7528SQL\u811a\u672c\u5f62\u5f0f\u5bfc\u5165\u3002 \u4e0b\u9762\u5206\u522b\u4ecb\u7ecd\u4e24\u79cd\u65b9\u6cd5\u3002 2. \u65b9\u6cd5\u4e00 SQL\u811a\u672c\u5f62\u5f0f \u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\uff1a 2.1. \u5bfc\u51faSQL\u811a\u672c \u5728\u539f\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\uff0c\u53ef\u4ee5\u7528phpMyAdmin\u5de5\u5177\uff0c\u6216\u8005mysqldump(mysqldump\u547d\u4ee4\u4f4d\u4e8emysql\/bin\/\u76ee\u5f55\u4e2d)\u547d\u4ee4\u884c\uff0c\u5bfc\u51faSQL\u811a\u672c\u3002 2.1.1 \u7528phpMyAdmin\u5de5\u5177 \u5bfc\u51fa\u9009\u9879\u4e2d\uff0c\u9009\u62e9\u5bfc\u51fa\u201c\u7ed3\u6784\u201d\u548c\u201c\u6570\u636e\u201d\uff0c\u4e0d\u8981\u6dfb\u52a0\u201cDrop DATABASE\u201d\u548c\u201cDrop TABLE\u201d\u9009\u9879\u3002 \u9009\u4e2d\u201c\u53e6\u5b58\u4e3a\u6587\u4ef6\u201d\u9009\u9879\uff0c\u5982\u679c\u6570\u636e\u6bd4\u8f83\u591a\uff0c\u53ef\u4ee5\u9009\u4e2d\u201cgzipped\u201d\u9009\u9879\u3002 \u5c06\u5bfc\u51fa\u7684SQL\u6587\u4ef6\u4fdd\u5b58\u4e0b\u6765\u3002 2.1.2 \u7528mysqldump\u547d\u4ee4\u884c \u547d\u4ee4\u683c\u5f0f mysqldump -u\u7528\u6237\u540d -p \u6570\u636e\u5e93\u540d &gt; \u6570\u636e\u5e93\u540d.sql \u8303\u4f8b\uff1a mysqldump -uroot -p abc &gt; abc.sql \uff08\u5bfc\u51fa\u6570\u636e\u5e93abc\u5230abc.sql\u6587\u4ef6\uff09 \u63d0\u793a\u8f93\u5165\u5bc6\u7801\u65f6\uff0c\u8f93\u5165\u8be5\u6570\u636e\u5e93\u7528\u6237\u540d\u7684\u5bc6\u7801\u3002 2.2. \u521b\u5efa\u7a7a\u7684\u6570\u636e\u5e93 \u901a\u8fc7\u4e3b\u63a7\u754c\u9762\/\u63a7\u5236\u9762\u677f\uff0c\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u3002\u5047\u8bbe\u6570\u636e\u5e93\u540d\u4e3aabc\uff0c\u6570\u636e\u5e93\u5168\u6743\u7528\u6237\u4e3aabc_f\u3002 2.3. \u5c06SQL\u811a\u672c\u5bfc\u5165\u6267\u884c \u540c\u6837\u662f\u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u7528phpMyAdmin\uff08mysql\u6570\u636e\u5e93\u7ba1\u7406\uff09\u5de5\u5177\uff0c\u6216\u8005mysql\u547d\u4ee4\u884c\u3002 2.3.1 \u7528phpMyAdmin\u5de5\u5177 \u4ece\u63a7\u5236\u9762\u677f\uff0c\u9009\u62e9\u521b\u5efa\u7684\u7a7a\u6570\u636e\u5e93\uff0c\u70b9\u201c\u7ba1\u7406\u201d\uff0c\u8fdb\u5165\u7ba1\u7406\u5de5\u5177\u9875\u9762\u3002 \u5728&#8221;SQL&#8221;\u83dc\u5355\u4e2d\uff0c\u6d4f\u89c8\u9009\u62e9\u521a\u624d\u5bfc\u51fa\u7684SQL\u6587\u4ef6\uff0c\u70b9\u51fb\u201c\u6267\u884c\u201d\u4ee5\u4e0a\u8f7d\u5e76\u6267\u884c\u3002 \u6ce8\u610f\uff1aphpMyAdmin\u5bf9\u4e0a\u8f7d\u7684\u6587\u4ef6\u5927\u5c0f\u6709\u9650\u5236\uff0cphp\u672c\u8eab\u5bf9\u4e0a\u8f7d\u6587\u4ef6\u5927\u5c0f\u4e5f\u6709\u9650\u5236\uff0c\u5982\u679c\u539f\u59cbsql\u6587\u4ef6 \u6bd4\u8f83\u5927\uff0c\u53ef\u4ee5\u5148\u7528gzip\u5bf9\u5b83\u8fdb\u884c\u538b\u7f29\uff0c\u5bf9\u4e8esql\u6587\u4ef6\u8fd9\u6837\u7684\u6587\u672c\u6587\u4ef6\uff0c\u53ef\u83b7\u5f971:5\u6216\u66f4\u9ad8\u7684\u538b\u7f29\u7387\u3002 gzip\u4f7f\u7528\u65b9\u6cd5\uff1a &hellip; <a href=\"https:\/\/www.strongd.net\/?p=1301\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u5982\u4f55\u5bfc\u5165\u5bfc\u51faMySQL\u6570\u636e\u5e93<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[196],"class_list":["post-1301","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql-mysqldump"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1301"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1301\/revisions"}],"predecessor-version":[{"id":1302,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1301\/revisions\/1302"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}