{"id":179520,"date":"2024-11-09T02:30:20","date_gmt":"2024-11-08T18:30:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/179520\/"},"modified":"2024-11-09T02:30:20","modified_gmt":"2024-11-08T18:30:20","slug":"%e5%a6%82%e4%bd%95%e9%81%a0%e7%a8%8b%e5%b0%8e%e5%87%ba-mysql-%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-mysql-%e6%95%b8%e6%93%9a%e5%ba%ab%e9%81%a0%e7%a8%8b%e5%b0%8e%e5%87%ba","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/179520\/","title":{"rendered":"\u5982\u4f55\u9060\u7a0b\u5c0e\u51fa MySQL \u6578\u64da\u5eab\uff1f (mysql \u6578\u64da\u5eab\u9060\u7a0b\u5c0e\u51fa)"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e9%81%a0%e7%a8%8b%e5%b0%8e%e5%87%ba-mysql-%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-fsKZcpRwsD\">\u5982\u4f55\u9060\u7a0b\u5c0e\u51fa MySQL \u6578\u64da\u5eab\uff1f<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u7ba1\u7406\u548c\u7dad\u8b77\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002MySQL \u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u7576\u9700\u8981\u5c07\u6578\u64da\u5eab\u7684\u5167\u5bb9\u5099\u4efd\u6216\u8f49\u79fb\u5230\u53e6\u4e00\u500b\u670d\u52d9\u5668\u6642\uff0c\u9060\u7a0b\u5c0e\u51fa MySQL \u6578\u64da\u5eab\u662f\u4e00\u500b\u5e38\u898b\u7684\u9700\u6c42\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u6709\u6548\u5730\u9032\u884c MySQL \u6578\u64da\u5eab\u7684\u9060\u7a0b\u5c0e\u51fa\u3002<\/p>\n<h2 id=\"%e6%ba%96%e5%82%99%e5%b7%a5%e4%bd%9c-fsKZcpRwsD\">\u6e96\u5099\u5de5\u4f5c<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u60a8\u64c1\u6709\u9060\u7a0b MySQL \u670d\u52d9\u5668\u7684\u8a2a\u554f\u6b0a\u9650\u3002<\/li>\n<li>\u60a8\u77e5\u9053\u6578\u64da\u5eab\u7684\u540d\u7a31\u3001\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002<\/li>\n<li>\u60a8\u7684\u672c\u5730\u6a5f\u5668\u4e0a\u5df2\u5b89\u88dd MySQL \u5ba2\u6236\u7aef\u5de5\u5177\u3002<\/li>\n<\/ul>\n<h2 id=\"%e4%bd%bf%e7%94%a8-mysqldump-%e5%91%bd%e4%bb%a4-fsKZcpRwsD\">\u4f7f\u7528 mysqldump \u547d\u4ee4<\/h2>\n<p>\u6700\u5e38\u7528\u7684\u9060\u7a0b\u5c0e\u51fa\u65b9\u6cd5\u662f\u4f7f\u7528 <code>mysqldump<\/code> \u547d\u4ee4\u3002\u9019\u662f\u4e00\u500b\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u4ee5\u5c07 MySQL \u6578\u64da\u5eab\u5c0e\u51fa\u70ba SQL \u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u57fa\u672c\u7684\u4f7f\u7528\u8a9e\u6cd5\uff1a<\/p>\n<pre><code>mysqldump -h [\u9060\u7a0b\u4e3b\u6a5f\u5730\u5740] -u [\u7528\u6236\u540d] -p [\u6578\u64da\u5eab\u540d\u7a31] &gt; [\u5c0e\u51fa\u6587\u4ef6\u540d].sql<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c\u60a8\u9700\u8981\u66ff\u63db\u4ee5\u4e0b\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><code>[\u9060\u7a0b\u4e3b\u6a5f\u5730\u5740]<\/code>\uff1a\u9060\u7a0b MySQL \u670d\u52d9\u5668\u7684 IP \u5730\u5740\u6216\u57df\u540d\u3002<\/li>\n<li><code>[\u7528\u6236\u540d]<\/code>\uff1a\u7528\u65bc\u767b\u9304 MySQL \u7684\u7528\u6236\u540d\u3002<\/li>\n<li><code>[\u6578\u64da\u5eab\u540d\u7a31]<\/code>\uff1a\u60a8\u8981\u5c0e\u51fa\u7684\u6578\u64da\u5eab\u540d\u7a31\u3002<\/li>\n<li><code>[\u5c0e\u51fa\u6587\u4ef6\u540d]<\/code>\uff1a\u60a8\u5e0c\u671b\u4fdd\u5b58\u7684 SQL \u6587\u4ef6\u540d\u7a31\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%a4%ba%e4%be%8b-fsKZcpRwsD\">\u793a\u4f8b<\/h3>\n<p>\u5047\u8a2d\u60a8\u8981\u5f9e IP \u70ba <code>192.168.1.100<\/code> \u7684\u9060\u7a0b\u670d\u52d9\u5668\u5c0e\u51fa\u540d\u70ba <code>my_database<\/code> \u7684\u6578\u64da\u5eab\uff0c\u4e26\u5c07\u5176\u4fdd\u5b58\u70ba <code>backup.sql<\/code>\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>mysqldump -h 192.168.1.100 -u root -p my_database &gt; backup.sql<\/code><\/pre>\n<p>\u57f7\u884c\u6b64\u547d\u4ee4\u5f8c\uff0c\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8f38\u5165\u5bc6\u78bc\u3002\u8f38\u5165\u6b63\u78ba\u7684\u5bc6\u78bc\u5f8c\uff0c\u6578\u64da\u5eab\u5c07\u88ab\u5c0e\u51fa\u5230\u7576\u524d\u76ee\u9304\u4e0b\u7684 <code>backup.sql<\/code> \u6587\u4ef6\u4e2d\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8-ssh-%e9%9a%a7%e9%81%93%e9%80%b2%e8%a1%8c%e5%ae%89%e5%85%a8%e5%b0%8e%e5%87%ba-fsKZcpRwsD\">\u4f7f\u7528 SSH \u96a7\u9053\u9032\u884c\u5b89\u5168\u5c0e\u51fa<\/h2>\n<p>\u5982\u679c\u60a8\u7684 MySQL \u670d\u52d9\u5668\u50c5\u5141\u8a31\u901a\u904e SSH \u9023\u63a5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 SSH \u96a7\u9053\u4f86\u5b89\u5168\u5730\u5c0e\u51fa\u6578\u64da\u5eab\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u8a2d\u7f6e SSH \u96a7\u9053\u7684\u6b65\u9a5f\uff1a<\/p>\n<pre><code>ssh -L 3306:localhost:3306 [\u7528\u6236\u540d]@[\u9060\u7a0b\u4e3b\u6a5f\u5730\u5740]<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u6703\u5c07\u672c\u5730\u7684 3306 \u7aef\u53e3\u8f49\u767c\u5230\u9060\u7a0b\u4e3b\u6a5f\u7684 3306 \u7aef\u53e3\u3002\u7136\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5728\u672c\u5730\u4f7f\u7528 <code>mysqldump<\/code> \u547d\u4ee4\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code>mysqldump -h 127.0.0.1 -u [\u7528\u6236\u540d] -p [\u6578\u64da\u5eab\u540d\u7a31] &gt; [\u5c0e\u51fa\u6587\u4ef6\u540d].sql<\/code><\/pre>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-fsKZcpRwsD\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u9032\u884c\u9060\u7a0b\u5c0e\u51fa\u6642\uff0c\u8acb\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd\u60a8\u7684\u9632\u706b\u7246\u8a2d\u7f6e\u5141\u8a31 MySQL \u7684\u7aef\u53e3\uff08\u9ed8\u8a8d\u70ba 3306\uff09\u901a\u904e\u3002<\/li>\n<li>\u5b9a\u671f\u5099\u4efd\u6578\u64da\u5eab\uff0c\u4ee5\u9632\u6578\u64da\u4e1f\u5931\u3002<\/li>\n<li>\u5728\u5c0e\u51fa\u5927\u578b\u6578\u64da\u5eab\u6642\uff0c\u8acb\u78ba\u4fdd\u6709\u8db3\u5920\u7684\u78c1\u789f\u7a7a\u9593\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-fsKZcpRwsD\">\u7e3d\u7d50<\/h2>\n<p>\u9060\u7a0b\u5c0e\u51fa MySQL \u6578\u64da\u5eab\u662f\u4e00\u500b\u91cd\u8981\u7684\u6280\u80fd\uff0c\u7121\u8ad6\u662f\u70ba\u4e86\u5099\u4efd\u9084\u662f\u6578\u64da\u9077\u79fb\u3002\u901a\u904e\u4f7f\u7528 <code>mysqldump<\/code> \u547d\u4ee4\u6216 SSH \u96a7\u9053\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u5c07\u6578\u64da\u5eab\u5c0e\u51fa\u5230\u672c\u5730\u7cfb\u7d71\u3002\u4e86\u89e3\u9019\u4e9b\u57fa\u672c\u64cd\u4f5c\u5f8c\uff0c\u60a8\u5c07\u80fd\u5920\u66f4\u6709\u6548\u5730\u7ba1\u7406\u60a8\u7684\u6578\u64da\u5eab\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c\u60a8\u7684 MySQL \u6578\u64da\u5eab\uff0c\u8acb\u8003\u616e\u6211\u5011\u7684\u670d\u52d9\u3002\u6211\u5011\u63d0\u4f9b\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u65b9\u6848\uff0c\u5e6b\u52a9\u60a8\u8f15\u9b06\u7ba1\u7406\u548c\u5099\u4efd\u6578\u64da\u5eab\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u9060\u7a0b\u5c0e\u51fa MySQL \u6578\u64da\u5eab\uff0c\u638c\u63e1\u4f7f\u7528\u547d\u4ee4\u884c\u548c\u5de5\u5177\u9032\u884c\u6578\u64da\u5099\u4efd\u7684\u6280\u5de7\uff0c\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-179520","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=179520"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179520\/revisions"}],"predecessor-version":[{"id":179521,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179520\/revisions\/179521"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=179520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=179520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=179520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}