{"id":6434,"date":"2024-11-14T12:34:41","date_gmt":"2024-11-14T04:34:41","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6434\/"},"modified":"2024-11-14T12:34:41","modified_gmt":"2024-11-14T04:34:41","slug":"mysql%e5%a6%82%e4%bd%95%e8%bf%9e%e6%8e%a5%e8%bf%9c%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6434\/","title":{"rendered":"mysql\u5982\u4f55\u8fde\u63a5\u8fdc\u7a0b"},"content":{"rendered":"<blockquote><p>\n  \u8981\u8fde\u63a5\u8fdc\u7a0b mysql \u670d\u52a1\u5668\uff0c\u9700\u8981\u4ee5\u4e0b\u4fe1\u606f\uff1a\u4e3b\u673a\u540d\u6216 ip \u5730\u5740\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u8fde\u63a5\uff1a\u83b7\u53d6\u8fdc\u7a0b\u670d\u52a1\u5668\u8fde\u63a5\u4fe1\u606f\u3002\u4f7f\u7528 mysql \u5ba2\u6237\u7aef\u5de5\u5177\u8fdb\u884c\u8fde\u63a5\u3002\u5bf9\u4e8e\u4e0d\u5141\u8bb8\u76f4\u63a5 tcp \u8fde\u63a5\u7684\u670d\u52a1\u5668\uff0c\u8bbe\u7f6e ssh \u96a7\u9053\u3002\u901a\u8fc7 ssh \u96a7\u9053\u8fde\u63a5\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/02\/2024080218130670360.jpg\" class=\"aligncenter\" title=\"mysql\u5982\u4f55\u8fde\u63a5\u8fdc\u7a0b\u63d2\u56fe\" alt=\"mysql\u5982\u4f55\u8fde\u63a5\u8fdc\u7a0b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u8fde\u63a5 MySQL \u8fdc\u7a0b\u670d\u52a1\u5668<\/strong><\/p>\n<p>\u8fde\u63a5\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u83b7\u53d6\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u8fde\u63a5\u4fe1\u606f<\/strong><\/p>\n<ul>\n<li> <strong>\u4e3b\u673a\u540d\u6216 IP \u5730\u5740\uff1a<\/strong>\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u7684\u5730\u5740\u3002<\/li>\n<li> <strong>\u7aef\u53e3\uff1a<\/strong>MySQL \u670d\u52a1\u5668\u76d1\u542c\u7684\u7aef\u53e3\uff0c\u9ed8\u8ba4\u503c\u4e3a 3306\u3002<\/li>\n<li> <strong>\u7528\u6237\u540d\uff1a<\/strong>\u5177\u6709\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\u6743\u9650\u7684\u7528\u6237\u540d\u3002<\/li>\n<li> <strong>\u5bc6\u7801\uff1a<\/strong>\u5bf9\u5e94\u7528\u6237\u7684\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528\u5ba2\u6237\u7aef\u5de5\u5177<\/strong><\/p>\n<p>\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u5de5\u5177\uff08\u5982 MySQL Workbench \u6216\u547d\u4ee4\u884c\u5de5\u5177 \uff09\u8fdb\u884c\u8fde\u63a5\u3002<\/p>\n<p><strong>\u547d\u4ee4\u884c\u5de5\u5177\u7528\u6cd5\uff08\u5047\u8bbe\u7528\u6237\u540d\u4e3a &#8216;remoteuser&#8217;\uff0c\u5bc6\u7801\u4e3a &#8216;remotepassword&#8217;\uff09\uff1a<\/strong><\/p>\n<pre>mysql -h [\u8fdc\u7a0b\u670d\u52a1\u5668\u4e3b\u673a\u540d\u6216 IP \u5730\u5740] -P [\u7aef\u53e3] -u remoteuser -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u5bc6\u7801\u3002\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u5373\u53ef\u5efa\u7acb\u8fde\u63a5\u3002<\/p>\n<p><strong>3. \u8bbe\u7f6e SSH \u96a7\u9053\uff08\u53ef\u9009\uff09<\/strong><\/p>\n<p>\u5982\u679c\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0d\u5141\u8bb8\u76f4\u63a5 TCP \u8fde\u63a5\uff0c\u5219\u9700\u8981\u4f7f\u7528 SSH \u96a7\u9053\u5efa\u7acb\u5b89\u5168\u8fde\u63a5\u3002<\/p>\n<p><strong>SSH \u96a7\u9053\u547d\u4ee4\uff08\u5047\u8bbe\u8fdc\u7a0b\u7528\u6237\u540d\u4e3a &#8216;sshuser&#8217;\uff0c\u8fdc\u7a0b\u4e3b\u673a\u540d\u4e3a &#8216;remotehost.com&#8217;\uff09\uff1a<\/strong><\/p>\n<pre>ssh -L 3306:localhost:3306 sshuser@remotehost.com<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u5728\u672c\u5730\u4e3b\u673a\u4e0a\u521b\u5efa\u4e00\u6761\u4ece\u7aef\u53e3 3306 \u8f6c\u53d1\u5230\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u7aef\u53e3 3306 \u7684 SSH \u96a7\u9053\u3002<\/p>\n<p><strong>4. \u901a\u8fc7 SSH \u96a7\u9053\u8fde\u63a5<\/strong><\/p>\n<p>\u5728\u5ba2\u6237\u7aef\u5de5\u5177\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8fde\u63a5\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre>127.0.0.1:3306  # \u672c\u5730\u96a7\u9053\u7aef\u53e3<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8be5\u8fde\u63a5\u5b57\u7b26\u4e32\u5c06\u5229\u7528 SSH \u96a7\u9053\u95f4\u63a5\u8fde\u63a5\u5230\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u8fde\u63a5\u8fdc\u7a0b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u8fde\u63a5\u8fdc\u7a0b mysql \u670d\u52a1\u5668\uff0c\u9700\u8981\u4ee5\u4e0b\u4fe1\u606f\uff1a\u4e3b\u673a\u540d\u6216 ip \u5730\u5740\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u8fde\u63a5\uff1a\u83b7\u53d6\u8fdc\u7a0b\u670d\u52a1\u5668\u8fde\u63a5\u4fe1\u606f\u3002\u4f7f\u7528 mysql \u5ba2\u6237\u7aef\u5de5\u5177\u8fdb\u884c\u8fde\u63a5\u3002\u5bf9\u4e8e\u4e0d\u5141\u8bb8\u76f4\u63a5 tcp \u8fde\u63a5\u7684\u670d\u52a1\u5668\uff0c\u8bbe\u7f6e ssh \u96a7\u9053\u3002\u901a\u8fc7 ssh \u96a7\u9053\u8fde\u63a5\u3002 \u5982\u4f55\u8fde\u63a5 MySQL \u8fdc\u7a0b\u670d\u52a1\u5668 \u8fde\u63a5\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u83b7\u53d6\u8fdc\u7a0b\u670d\u52a1\u5668\u7684\u8fde\u63a5\u4fe1\u606f \u4e3b\u673a\u540d\u6216 IP \u5730\u5740\uff1a\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u7684\u5730\u5740\u3002 \u7aef\u53e3\uff1aMySQL \u670d\u52a1\u5668\u76d1\u542c\u7684\u7aef\u53e3\uff0c\u9ed8\u8ba4\u503c\u4e3a 3306\u3002 \u7528\u6237\u540d\uff1a\u5177\u6709\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\u6743\u9650\u7684\u7528\u6237\u540d\u3002 \u5bc6\u7801\uff1a\u5bf9\u5e94\u7528\u6237\u7684\u5bc6\u7801\u3002 2. \u4f7f\u7528\u5ba2\u6237\u7aef\u5de5\u5177 \u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u5de5\u5177\uff08\u5982 MySQL Workbench \u6216\u547d\u4ee4\u884c\u5de5\u5177 \uff09\u8fdb\u884c\u8fde\u63a5\u3002 \u547d\u4ee4\u884c\u5de5\u5177\u7528\u6cd5\uff08\u5047\u8bbe\u7528\u6237\u540d\u4e3a &#8216;remoteuser&#8217;\uff0c\u5bc6\u7801\u4e3a &#8216;remotepassword&#8217;\uff09\uff1a mysql -h [\u8fdc\u7a0b\u670d\u52a1\u5668\u4e3b\u673a\u540d\u6216 IP \u5730\u5740] -P [\u7aef\u53e3] -u remoteuser -p \u767b\u5f55\u540e\u590d\u5236 \u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u5bc6\u7801\u3002\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u5373\u53ef\u5efa\u7acb\u8fde\u63a5\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6434","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6434"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6434\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}