{"id":5287,"date":"2024-11-14T13:23:24","date_gmt":"2024-11-14T05:23:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5287\/"},"modified":"2024-11-14T13:23:24","modified_gmt":"2024-11-14T05:23:24","slug":"mysql%e6%96%b0%e7%94%a8%e6%88%b7%e6%80%8e%e4%b9%88%e5%88%9b%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5287\/","title":{"rendered":"mysql\u65b0\u7528\u6237\u600e\u4e48\u521b\u5efa"},"content":{"rendered":"<blockquote><p>\n  \u4e3a\u4e86\u5728 mysql \u4e2d\u521b\u5efa\u65b0\u7528\u6237\uff0c\u9700\u8981\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u767b\u5f55 mysql \u670d\u52a1\u5668\u3002\u4f7f\u7528 create user \u8bed\u53e5\u521b\u5efa\u65b0\u7528\u6237\u3002\u4f7f\u7528 grant \u8bed\u53e5\u6388\u4e88\u65b0\u7528\u6237\u6743\u9650\u3002\u4f7f\u7528 flush privileges \u8bed\u53e5\u5237\u65b0\u6743\u9650\u8868\u3002\u9000\u51fa\u5e76\u4f7f\u7528\u65b0\u7528\u6237\u540d\u548c\u5bc6\u7801\u91cd\u65b0\u767b\u5f55\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052618274876388.jpg\" class=\"aligncenter\" title=\"mysql\u65b0\u7528\u6237\u600e\u4e48\u521b\u5efa\u63d2\u56fe\" alt=\"mysql\u65b0\u7528\u6237\u600e\u4e48\u521b\u5efa\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4e3a MySQL \u521b\u5efa\u65b0\u7528\u6237<\/strong><\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u767b\u5f55 MySQL \u670d\u52a1\u5668<\/strong><\/p>\n<p>\u4f7f\u7528\u60a8\u73b0\u6709\u7684\u7528\u6237\u5e10\u6237\u767b\u5f55 MySQL \u670d\u52a1\u5668\uff1a<\/p>\n<pre>mysql -u existing_user -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 2\uff1a\u521b\u5efa\u65b0\u7528\u6237<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u521b\u5efa\u65b0\u7528\u6237\uff1a<\/p>\n<pre>CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'new_password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 new_user \u66ff\u6362\u4e3a\u60a8\u8981\u521b\u5efa\u7684\u65b0\u7528\u6237\u540d\u3002<\/li>\n<li>\u5c06 new_password \u66ff\u6362\u4e3a\u65b0\u7528\u6237\u7684\u5bc6\u7801\u3002<\/li>\n<li>localhost \u6307\u5b9a\u7528\u6237\u53ea\u80fd\u4ece\u672c\u5730\u8ba1\u7b97\u673a\u8bbf\u95ee\u6570\u636e\u5e93\u3002\u60a8\u53ef\u4ee5\u5c06\u5176\u66f4\u6539\u4e3a\u4efb\u4f55\u5141\u8bb8\u7684 IP \u5730\u5740\u6216\u4e3b\u673a\u540d\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 3\uff1a\u6388\u4e88\u6743\u9650<\/strong><\/p>\n<p>\u65b0\u7528\u6237\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u60a8\u9700\u8981\u5411\u5176\u6388\u4e88\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>*.* \u6388\u4e88\u5bf9\u6240\u6709\u6570\u636e\u5e93\u548c\u8868\u7684\u6240\u6709\u6743\u9650\u3002<\/li>\n<li>\u60a8\u8fd8\u53ef\u4ee5\u6307\u5b9a\u7279\u5b9a\u6570\u636e\u5e93\u6216\u8868\u4ee5\u6388\u4e88\u6709\u9650\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 4\uff1a\u5237\u65b0\u6743\u9650<\/strong><\/p>\n<p>\u4e3a\u4e86\u4f7f\u66f4\u6539\u751f\u6548\uff0c\u60a8\u9700\u8981\u5237\u65b0\u6743\u9650\u8868\uff1a<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 5\uff1a\u9000\u51fa\u5e76\u91cd\u65b0\u767b\u5f55<\/strong><\/p>\n<p>\u9000\u51fa MySQL \u670d\u52a1\u5668\uff0c\u7136\u540e\u4f7f\u7528\u65b0\u7528\u6237\u540d\u548c\u5bc6\u7801\u91cd\u65b0\u767b\u5f55\uff1a<\/p>\n<pre>exit\nmysql -u new_user -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u65b0\u7528\u6237\u600e\u4e48\u521b\u5efa\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>\u4e3a\u4e86\u5728 mysql \u4e2d\u521b\u5efa\u65b0\u7528\u6237\uff0c\u9700\u8981\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u767b\u5f55 mysql \u670d\u52a1\u5668\u3002\u4f7f\u7528 create user \u8bed\u53e5\u521b\u5efa\u65b0\u7528\u6237\u3002\u4f7f\u7528 grant \u8bed\u53e5\u6388\u4e88\u65b0\u7528\u6237\u6743\u9650\u3002\u4f7f\u7528 flush privileges \u8bed\u53e5\u5237\u65b0\u6743\u9650\u8868\u3002\u9000\u51fa\u5e76\u4f7f\u7528\u65b0\u7528\u6237\u540d\u548c\u5bc6\u7801\u91cd\u65b0\u767b\u5f55\u3002 \u5982\u4f55\u4e3a MySQL \u521b\u5efa\u65b0\u7528\u6237 \u6b65\u9aa4 1\uff1a\u767b\u5f55 MySQL \u670d\u52a1\u5668 \u4f7f\u7528\u60a8\u73b0\u6709\u7684\u7528\u6237\u5e10\u6237\u767b\u5f55 MySQL \u670d\u52a1\u5668\uff1a mysql -u existing_user -p \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa4 2\uff1a\u521b\u5efa\u65b0\u7528\u6237 \u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u521b\u5efa\u65b0\u7528\u6237\uff1a CREATE USER &#8216;new_user&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;new_password&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5c06 new_user \u66ff\u6362\u4e3a\u60a8\u8981\u521b\u5efa\u7684\u65b0\u7528\u6237\u540d\u3002 \u5c06 new_password \u66ff\u6362\u4e3a\u65b0\u7528\u6237\u7684\u5bc6\u7801\u3002 localhost \u6307\u5b9a\u7528\u6237\u53ea\u80fd\u4ece\u672c\u5730\u8ba1\u7b97\u673a\u8bbf\u95ee\u6570\u636e\u5e93\u3002\u60a8\u53ef\u4ee5\u5c06\u5176\u66f4\u6539\u4e3a\u4efb\u4f55\u5141\u8bb8\u7684 IP \u5730\u5740\u6216\u4e3b\u673a\u540d\u3002 \u6b65\u9aa4 3\uff1a\u6388\u4e88\u6743\u9650 \u65b0\u7528\u6237\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u60a8\u9700\u8981\u5411\u5176\u6388\u4e88\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a GRANT ALL PRIVILEGES ON [&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-5287","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5287","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=5287"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5287\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}