{"id":6417,"date":"2024-11-14T13:17:31","date_gmt":"2024-11-14T05:17:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6417\/"},"modified":"2024-11-14T13:17:31","modified_gmt":"2024-11-14T05:17:31","slug":"mysql%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6417\/","title":{"rendered":"mysql\u8fdc\u7a0b\u8fde\u63a5\u547d\u4ee4"},"content":{"rendered":"<blockquote><p>\n  mysql \u8fdc\u7a0b\u8fde\u63a5\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u6b65\u9aa4\uff1a1. \u83b7\u53d6\u6570\u636e\u5e93\u4fe1\u606f\uff08ip\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff09\uff1b2. \u914d\u7f6e\u8fdc\u7a0b\u8bbf\u95ee\uff08bind-address \u9009\u9879\uff09\uff1b3. \u8bbe\u7f6e\u9632\u706b\u5899\u89c4\u5219\uff08\u6253\u5f00 mysql \u7aef\u53e3\uff09\uff1b4. \u5efa\u7acb\u8fdc\u7a0b\u8fde\u63a5\uff08\u4f7f\u7528 mysql \u547d\u4ee4\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/02\/2024080207364920669.jpg\" class=\"aligncenter\" title=\"mysql\u8fdc\u7a0b\u8fde\u63a5\u547d\u4ee4\u63d2\u56fe\" alt=\"mysql\u8fdc\u7a0b\u8fde\u63a5\u547d\u4ee4\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u8fdc\u7a0b\u8fde\u63a5\u547d\u4ee4<\/strong><\/p>\n<p>\u8fdc\u7a0b\u8fde\u63a5 MySQL \u6570\u636e\u5e93\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a<\/p>\n<p><strong>1. \u83b7\u53d6\u6570\u636e\u5e93\u4fe1\u606f<\/strong><\/p>\n<p>\u83b7\u53d6\u6570\u636e\u5e93\u7684 IP \u5730\u5740\u3001\u7aef\u53e3\u53f7\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u8fd9\u4e9b\u4fe1\u606f\u901a\u5e38\u5b58\u50a8\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982 \/etc\/\/my.cnf\u3002<\/p>\n<p><strong>2. \u914d\u7f6e\u8fdc\u7a0b\u8bbf\u95ee<\/strong><\/p>\n<p>\u5728 MySQL \u670d\u52a1\u5668\u4e0a\u914d\u7f6e\u8fdc\u7a0b\u8bbf\u95ee\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91 my.cnf \u914d\u7f6e\u6587\u4ef6\u5e76\u8bbe\u7f6e bind-address \u9009\u9879\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>bind-address = 0.0.0.0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u8bbe\u7f6e\u9632\u706b\u5899\u89c4\u5219<\/strong><\/p>\n<p>\u5728\u670d\u52a1\u5668\u7684\u9632\u706b\u5899\u4e2d\u6253\u5f00 MySQL \u7aef\u53e3 (\u9ed8\u8ba4\u7aef\u53e3 3306)\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u4f7f\u7528 UFW \u9632\u706b\u5899\u7684 Ubuntu \u7cfb\u7edf\uff0c\u53ef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo ufw allow 3306\/tcp<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u5efa\u7acb\u8fdc\u7a0b\u8fde\u63a5<\/strong><\/p>\n<p>\u4f7f\u7528 mysql \u547d\u4ee4\u5efa\u7acb\u8fdc\u7a0b\u8fde\u63a5\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>mysql -h [IP \u5730\u5740] -P [\u7aef\u53e3\u53f7] -u [\u7528\u6237\u540d] -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u8fde\u63a5\u5230 IP \u5730\u5740\u4e3a 192.168.1.10\u3001\u7aef\u53e3\u53f7\u4e3a 3306\u3001\u7528\u6237\u540d\u4e3a root \u7684 MySQL \u670d\u52a1\u5668\uff0c\u53ef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysql -h 192.168.1.10 -P 3306 -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u5373\u53ef\u5efa\u7acb\u8fde\u63a5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8fdc\u7a0b\u8fde\u63a5\u547d\u4ee4\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>mysql \u8fdc\u7a0b\u8fde\u63a5\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u6b65\u9aa4\uff1a1. \u83b7\u53d6\u6570\u636e\u5e93\u4fe1\u606f\uff08ip\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff09\uff1b2. \u914d\u7f6e\u8fdc\u7a0b\u8bbf\u95ee\uff08bind-address \u9009\u9879\uff09\uff1b3. \u8bbe\u7f6e\u9632\u706b\u5899\u89c4\u5219\uff08\u6253\u5f00 mysql \u7aef\u53e3\uff09\uff1b4. \u5efa\u7acb\u8fdc\u7a0b\u8fde\u63a5\uff08\u4f7f\u7528 mysql \u547d\u4ee4\uff09\u3002 MySQL \u8fdc\u7a0b\u8fde\u63a5\u547d\u4ee4 \u8fdc\u7a0b\u8fde\u63a5 MySQL \u6570\u636e\u5e93\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a 1. \u83b7\u53d6\u6570\u636e\u5e93\u4fe1\u606f \u83b7\u53d6\u6570\u636e\u5e93\u7684 IP \u5730\u5740\u3001\u7aef\u53e3\u53f7\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u8fd9\u4e9b\u4fe1\u606f\u901a\u5e38\u5b58\u50a8\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982 \/etc\/\/my.cnf\u3002 2. \u914d\u7f6e\u8fdc\u7a0b\u8bbf\u95ee \u5728 MySQL \u670d\u52a1\u5668\u4e0a\u914d\u7f6e\u8fdc\u7a0b\u8bbf\u95ee\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91 my.cnf \u914d\u7f6e\u6587\u4ef6\u5e76\u8bbe\u7f6e bind-address \u9009\u9879\u6765\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a bind-address = 0.0.0.0 \u767b\u5f55\u540e\u590d\u5236 3. \u8bbe\u7f6e\u9632\u706b\u5899\u89c4\u5219 \u5728\u670d\u52a1\u5668\u7684\u9632\u706b\u5899\u4e2d\u6253\u5f00 MySQL \u7aef\u53e3 (\u9ed8\u8ba4\u7aef\u53e3 3306)\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u4f7f\u7528 UFW \u9632\u706b\u5899\u7684 Ubuntu \u7cfb\u7edf\uff0c\u53ef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo ufw allow 3306\/tcp \u767b\u5f55\u540e\u590d\u5236 4. \u5efa\u7acb\u8fdc\u7a0b\u8fde\u63a5 \u4f7f\u7528 mysql [&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-6417","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6417","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=6417"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6417\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}