{"id":5491,"date":"2024-11-14T13:30:52","date_gmt":"2024-11-14T05:30:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5491\/"},"modified":"2024-11-14T13:30:52","modified_gmt":"2024-11-14T05:30:52","slug":"mysql%e9%94%99%e8%af%af1042%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5491\/","title":{"rendered":"mysql\u9519\u8bef1042\u600e\u4e48\u89e3\u51b3"},"content":{"rendered":"<blockquote><p>\n  \u89e3\u51b3 mysql \u9519\u8bef 1042 &#8220;\u672a\u6388\u6743\u8fde\u63a5\u5230\u6570\u636e\u5e93&#8221;\uff1a\u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u5426\u5177\u6709\u8bbf\u95ee\u6743\u9650\u3002\u6388\u4e88\u5fc5\u8981\u7684\u6743\u9650\uff08select\u3001insert\u3001update\u3001delete\uff09\u3002\u91cd\u542f mysql \u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\u3002\u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e\u662f\u5426\u5141\u8bb8\u8fde\u63a5\u3002\u9a8c\u8bc1 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 bind-address \u8bbe\u7f6e\u662f\u5426\u5141\u8bb8\u8fde\u63a5\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052904182543093.jpg\" class=\"aligncenter\" title=\"mysql\u9519\u8bef1042\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" alt=\"mysql\u9519\u8bef1042\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3 MySQL \u9519\u8bef 1042<\/strong><\/p>\n<p>MySQL \u9519\u8bef 1042 &#8220;\u672a\u6388\u6743\u8fde\u63a5\u5230\u6570\u636e\u5e93&#8221;\u901a\u5e38\u8868\u793a\u6570\u636e\u5e93\u8fde\u63a5\u5b58\u5728\u6743\u9650\u95ee\u9898\u3002\u89e3\u51b3\u6b64\u9519\u8bef\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p><strong>1. \u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801<\/strong><\/p>\n<p>\u786e\u4fdd\u6240\u4f7f\u7528\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u4e0e\u6570\u636e\u5e93\u6743\u9650\u76f8\u5339\u914d\u3002\u6838\u5bf9\u7528\u6237\u7279\u6743\uff0c\u786e\u4fdd\u8be5\u7528\u6237\u5177\u6709\u8bbf\u95ee\u8be5\u6570\u636e\u5e93\u7684\u6743\u9650\u3002<\/p>\n<p><strong>2. \u6388\u4e88\u6743\u9650<\/strong><\/p>\n<p>\u5982\u679c\u7528\u6237\u6ca1\u6709\u9002\u5f53\u7684\u6743\u9650\uff0c\u8bf7\u6388\u4e88\u4ed6\u4eec\u5fc5\u8981\u7684\u6743\u9650\uff1a<\/p>\n<pre>GRANT &lt;\u6743\u9650&gt; ON &lt;\u6570\u636e\u5e93\u540d&gt;.* TO '&lt;\u7528\u6237\u540d&gt;'@'&lt;\u4e3b\u673a\u540d&gt;';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0c\u53ef\u4ee5\u662f\uff1a<\/p>\n<ul>\n<li>SELECT\uff1a\u5141\u8bb8\u8bfb\u53d6\u6570\u636e<\/li>\n<li>INSERT\uff1a\u5141\u8bb8\u63d2\u5165\u6570\u636e<\/li>\n<li>UPDATE\uff1a\u5141\u8bb8\u66f4\u65b0\u6570\u636e<\/li>\n<li>DELETE\uff1a\u5141\u8bb8\u5220\u9664\u6570\u636e<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u662f\uff1a<\/p>\n<ul>\n<li>%\uff1a\u5141\u8bb8\u4efb\u4f55\u4e3b\u673a<\/li>\n<li>localhost\uff1a\u4ec5\u5141\u8bb8\u672c\u5730\u8fde\u63a5<\/li>\n<li>\u7279\u5b9a\u4e3b\u673a\u540d\u6216 IP \u5730\u5740<\/li>\n<\/ul>\n<p><strong>3. \u5237\u65b0\u6743\u9650<\/strong><\/p>\n<p>\u6388\u4e88\u6743\u9650\u540e\uff0c\u9700\u8981\u5237\u65b0\u6743\u9650\u8868\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u91cd\u542f MySQL \u670d\u52a1<\/strong><\/p>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u91cd\u542f MySQL \u670d\u52a1\u4ee5\u5e94\u7528\u6743\u9650\u66f4\u6539\uff1a<\/p>\n<pre>sudo service mysql restart<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e<\/strong><\/p>\n<p>\u786e\u4fdd\u9632\u706b\u5899\u5141\u8bb8\u4ece\u6388\u6743\u4e3b\u673a\u8fdb\u884c MySQL \u8fde\u63a5\u3002\u8bf7\u5728\u9632\u706b\u5899\u4e2d\u6253\u5f00\u5fc5\u8981\u7684\u7aef\u53e3\uff08\u901a\u5e38\u662f 3306\uff09\u3002<\/p>\n<p><strong>6. \u68c0\u67e5 MySQL \u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<p>\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\uff08\u901a\u5e38\u4e3a \/etc\/\/my.cnf\uff09\uff0c\u786e\u4fdd bind-address \u8bbe\u7f6e\u5141\u8bb8\u6765\u81ea\u6388\u6743\u4e3b\u673a\u7684\u8fde\u63a5\u3002<\/p>\n<p><strong>7. \u5176\u4ed6\u539f\u56e0<\/strong><\/p>\n<p>\u5176\u4ed6\u53ef\u80fd\u5bfc\u81f4\u9519\u8bef 1042 \u7684\u539f\u56e0\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u6570\u636e\u5e93\u670d\u52a1\u5668\u5df2\u5173\u95ed<\/li>\n<li>\u7f51\u7edc\u8fde\u63a5\u95ee\u9898<\/li>\n<li>\u635f\u574f\u7684\u6570\u636e\u5e93\u6587\u4ef6<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9519\u8bef1042\u600e\u4e48\u89e3\u51b3\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>\u89e3\u51b3 mysql \u9519\u8bef 1042 &#8220;\u672a\u6388\u6743\u8fde\u63a5\u5230\u6570\u636e\u5e93&#8221;\uff1a\u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u5426\u5177\u6709\u8bbf\u95ee\u6743\u9650\u3002\u6388\u4e88\u5fc5\u8981\u7684\u6743\u9650\uff08select\u3001insert\u3001update\u3001delete\uff09\u3002\u91cd\u542f mysql \u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\u3002\u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e\u662f\u5426\u5141\u8bb8\u8fde\u63a5\u3002\u9a8c\u8bc1 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 bind-address \u8bbe\u7f6e\u662f\u5426\u5141\u8bb8\u8fde\u63a5\u3002 \u5982\u4f55\u89e3\u51b3 MySQL \u9519\u8bef 1042 MySQL \u9519\u8bef 1042 &#8220;\u672a\u6388\u6743\u8fde\u63a5\u5230\u6570\u636e\u5e93&#8221;\u901a\u5e38\u8868\u793a\u6570\u636e\u5e93\u8fde\u63a5\u5b58\u5728\u6743\u9650\u95ee\u9898\u3002\u89e3\u51b3\u6b64\u9519\u8bef\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a 1. \u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801 \u786e\u4fdd\u6240\u4f7f\u7528\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u4e0e\u6570\u636e\u5e93\u6743\u9650\u76f8\u5339\u914d\u3002\u6838\u5bf9\u7528\u6237\u7279\u6743\uff0c\u786e\u4fdd\u8be5\u7528\u6237\u5177\u6709\u8bbf\u95ee\u8be5\u6570\u636e\u5e93\u7684\u6743\u9650\u3002 2. \u6388\u4e88\u6743\u9650 \u5982\u679c\u7528\u6237\u6ca1\u6709\u9002\u5f53\u7684\u6743\u9650\uff0c\u8bf7\u6388\u4e88\u4ed6\u4eec\u5fc5\u8981\u7684\u6743\u9650\uff1a GRANT &lt;\u6743\u9650&gt; ON &lt;\u6570\u636e\u5e93\u540d&gt;.* TO &#8216;&lt;\u7528\u6237\u540d&gt;&#8217;@'&lt;\u4e3b\u673a\u540d&gt;&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c\u53ef\u4ee5\u662f\uff1a SELECT\uff1a\u5141\u8bb8\u8bfb\u53d6\u6570\u636e INSERT\uff1a\u5141\u8bb8\u63d2\u5165\u6570\u636e UPDATE\uff1a\u5141\u8bb8\u66f4\u65b0\u6570\u636e DELETE\uff1a\u5141\u8bb8\u5220\u9664\u6570\u636e \u53ef\u4ee5\u662f\uff1a %\uff1a\u5141\u8bb8\u4efb\u4f55\u4e3b\u673a localhost\uff1a\u4ec5\u5141\u8bb8\u672c\u5730\u8fde\u63a5 \u7279\u5b9a\u4e3b\u673a\u540d\u6216 IP \u5730\u5740 3. \u5237\u65b0\u6743\u9650 \u6388\u4e88\u6743\u9650\u540e\uff0c\u9700\u8981\u5237\u65b0\u6743\u9650\u8868\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a FLUSH PRIVILEGES; \u767b\u5f55\u540e\u590d\u5236 4. \u91cd\u542f MySQL \u670d\u52a1 \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u91cd\u542f 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-5491","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5491","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=5491"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5491\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}