{"id":5149,"date":"2024-11-14T10:02:35","date_gmt":"2024-11-14T02:02:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5149\/"},"modified":"2024-11-14T10:02:35","modified_gmt":"2024-11-14T02:02:35","slug":"mysql%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5%e6%80%8e%e4%b9%88%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5149\/","title":{"rendered":"mysql\u8fdc\u7a0b\u8fde\u63a5\u600e\u4e48\u7528"},"content":{"rendered":"<blockquote><p>\n  \u8fdc\u7a0b\u8fde\u63a5 mysql \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a\u542f\u7528\u8fdc\u7a0b\u8fde\u63a5\uff08\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u548c\u91cd\u542f\u670d\u52a1\u5668\uff09\uff1b\u521b\u5efa\u5177\u6709\u8fdc\u7a0b\u8fde\u63a5\u6743\u9650\u7684\u8fdc\u7a0b\u7528\u6237\uff1b\u5141\u8bb8\u5916\u90e8\u8fde\u63a5\uff08\u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e\uff09\uff1b\u4f7f\u7528 mysql \u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u8f93\u5165\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u8fdc\u7a0b\u670d\u52a1\u5668\u7684 ip \u5730\u5740\u6216\u4e3b\u673a\u540d\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/22\/2024052217122214759.jpg\" class=\"aligncenter\" title=\"mysql\u8fdc\u7a0b\u8fde\u63a5\u600e\u4e48\u7528\u63d2\u56fe\" alt=\"mysql\u8fdc\u7a0b\u8fde\u63a5\u600e\u4e48\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u8fdc\u7a0b\u8fde\u63a5\u6307\u5357<\/strong><\/p>\n<p>MySQL \u8fdc\u7a0b\u8fde\u63a5\u5141\u8bb8\u7528\u6237\u4ece\u5176\u4ed6\u4f4d\u7f6e\u8bbf\u95ee\u548c\u7ba1\u7406\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5b9e\u73b0\u8fdc\u7a0b\u8fde\u63a5\uff1a<\/p>\n<p><strong>1. \u542f\u7528\u8fdc\u7a0b\u8fde\u63a5<\/strong><\/p>\n<ul>\n<li>\u5728 MySQL \u670d\u52a1\u5668\u4e0a\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6 \/etc\/\/my.cnf\u3002<\/li>\n<li>\u5728 [mysqld] \u90e8\u5206\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/li>\n<\/ul>\n<pre>bind-address = 0.0.0.0<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u91cd\u542f MySQL \u670d\u52a1\u5668\u3002<\/li>\n<\/ul>\n<p><strong>2. \u521b\u5efa\u8fdc\u7a0b\u7528\u6237<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u5177\u6709\u8fdc\u7a0b\u8fde\u63a5\u6743\u9650\u7684\u65b0\u7528\u6237\uff1a<\/li>\n<\/ul>\n<pre>GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u66ff\u6362 username \u548c password \u4e3a\u6240\u9700\u7684\u503c\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5141\u8bb8\u5916\u90e8\u8fde\u63a5<\/strong><\/p>\n<ul>\n<li>\u68c0\u67e5 MySQL \u670d\u52a1\u5668\u7684\u9632\u706b\u5899\u8bbe\u7f6e\u5e76\u786e\u4fdd\u5df2\u5141\u8bb8\u8fdc\u7a0b\u8fde\u63a5\u3002\u5bf9\u4e8e Linux \u7cfb\u7edf\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>sudo ufw allow 3306\/tcp<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5bf9\u4e8e Windows \u7cfb\u7edf\uff0c\u6dfb\u52a0 MySQL \u7aef\u53e3\uff083306\uff09\u5230 Windows \u9632\u706b\u5899\u4e2d\u3002<\/li>\n<\/ul>\n<p><strong>4. \u8fdc\u7a0b\u8fde\u63a5<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\uff08\u4f8b\u5982 MySQL Workbench \u6216\u547d\u4ee4\u884c\uff09\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002<\/li>\n<li>\u8f93\u5165\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u8fdc\u7a0b\u670d\u52a1\u5668\u7684 IP \u5730\u5740\u6216\u4e3b\u673a\u540d\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>mysql -u username -p -h remote_server_ip_address<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 remote_server_ip_address \u66ff\u6362\u4e3a\u8fdc\u7a0b MySQL \u670d\u52a1\u5668\u7684 IP \u5730\u5740\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8fdc\u7a0b\u8fde\u63a5\u600e\u4e48\u7528\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>\u8fdc\u7a0b\u8fde\u63a5 mysql \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a\u542f\u7528\u8fdc\u7a0b\u8fde\u63a5\uff08\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u548c\u91cd\u542f\u670d\u52a1\u5668\uff09\uff1b\u521b\u5efa\u5177\u6709\u8fdc\u7a0b\u8fde\u63a5\u6743\u9650\u7684\u8fdc\u7a0b\u7528\u6237\uff1b\u5141\u8bb8\u5916\u90e8\u8fde\u63a5\uff08\u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e\uff09\uff1b\u4f7f\u7528 mysql \u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u8f93\u5165\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u8fdc\u7a0b\u670d\u52a1\u5668\u7684 ip \u5730\u5740\u6216\u4e3b\u673a\u540d\u3002 MySQL \u8fdc\u7a0b\u8fde\u63a5\u6307\u5357 MySQL \u8fdc\u7a0b\u8fde\u63a5\u5141\u8bb8\u7528\u6237\u4ece\u5176\u4ed6\u4f4d\u7f6e\u8bbf\u95ee\u548c\u7ba1\u7406\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5b9e\u73b0\u8fdc\u7a0b\u8fde\u63a5\uff1a 1. \u542f\u7528\u8fdc\u7a0b\u8fde\u63a5 \u5728 MySQL \u670d\u52a1\u5668\u4e0a\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6 \/etc\/\/my.cnf\u3002 \u5728 [mysqld] \u90e8\u5206\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a bind-address = 0.0.0.0 \u767b\u5f55\u540e\u590d\u5236 \u91cd\u542f MySQL \u670d\u52a1\u5668\u3002 2. \u521b\u5efa\u8fdc\u7a0b\u7528\u6237 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u5177\u6709\u8fdc\u7a0b\u8fde\u63a5\u6743\u9650\u7684\u65b0\u7528\u6237\uff1a GRANT ALL PRIVILEGES ON *.* TO &#8216;username&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;password&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u66ff\u6362 username \u548c password \u4e3a\u6240\u9700\u7684\u503c\u3002 3. \u5141\u8bb8\u5916\u90e8\u8fde\u63a5 \u68c0\u67e5 MySQL \u670d\u52a1\u5668\u7684\u9632\u706b\u5899\u8bbe\u7f6e\u5e76\u786e\u4fdd\u5df2\u5141\u8bb8\u8fdc\u7a0b\u8fde\u63a5\u3002\u5bf9\u4e8e Linux \u7cfb\u7edf\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo ufw [&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-5149","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5149","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=5149"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5149\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}