{"id":5245,"date":"2024-11-14T09:38:20","date_gmt":"2024-11-14T01:38:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5245\/"},"modified":"2024-11-14T09:38:20","modified_gmt":"2024-11-14T01:38:20","slug":"mysql%e6%80%8e%e4%b9%88%e8%8e%b7%e5%be%97%e6%9d%83%e9%99%90","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5245\/","title":{"rendered":"mysql\u600e\u4e48\u83b7\u5f97\u6743\u9650"},"content":{"rendered":"<blockquote><p>\n  \u8981\u83b7\u5f97 mysql \u6743\u9650\uff0c\u9700\u8981\u521b\u5efa\u7528\u6237\u3001\u6388\u4e88\u6743\u9650\u3001\u5237\u65b0\u6743\u9650\u5e76\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a\u521b\u5efa\u7528\u6237\uff1a\u4f7f\u7528 create user \u8bed\u53e5\u5e76\u6307\u5b9a\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u6388\u4e88\u6743\u9650\uff1a\u4f7f\u7528 grant \u8bed\u53e5\u6388\u4e88\u7279\u5b9a\u6570\u636e\u5e93\u6216\u8868\u7684\u6743\u9650\u3002\u5237\u65b0\u6743\u9650\uff1a\u4f7f\u7528 flush privileges \u8bed\u53e5\u66f4\u65b0\u6743\u9650\u8868\u3002\u8fde\u63a5\u6570\u636e\u5e93\uff1a\u4f7f\u7528\u65b0\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052617251078804.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u83b7\u5f97\u6743\u9650\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u83b7\u5f97\u6743\u9650\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u83b7\u5f97 MySQL \u6743\u9650<\/strong><\/p>\n<p>\u8981\u83b7\u5f97 MySQL \u6570\u636e\u5e93\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<p><strong>1. \u521b\u5efa\u7528\u6237<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 CREATE USER \u8bed\u53e5\u521b\u5efa\u65b0\u7528\u6237\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>CREATE USER 'new_user'@'%' IDENTIFIED BY 'password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 &#8216;new_user&#8217; \u66ff\u6362\u4e3a\u60a8\u8981\u521b\u5efa\u7684\u7528\u6237\u540d\u3002<\/li>\n<li>\u5c06 &#8216;password&#8217; \u66ff\u6362\u4e3a\u7528\u6237\u5bc6\u7801\u3002<\/li>\n<li>&#8216;%&#8217; \u8868\u793a\u5141\u8bb8\u7528\u6237\u4ece\u4efb\u4f55\u4e3b\u673a\u8bbf\u95ee\u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<p><strong>2. \u6388\u4e88\u6743\u9650<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 GRANT \u8bed\u53e5\u6388\u4e88\u7528\u6237\u5bf9\u7279\u5b9a\u6570\u636e\u5e93\u6216\u8868\u7684\u6743\u9650\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>GRANT ALL PRIVILEGES ON database_name.* TO 'new_user'@'%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 database_name \u66ff\u6362\u4e3a\u8981\u6388\u4e88\u6743\u9650\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002<\/li>\n<li>ALL PRIVILEGES \u6388\u4e88\u7528\u6237\u5bf9\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\u3002<\/li>\n<li>&#8216;new_user&#8217;@&#8217;%&#8217; \u6307\u5b9a\u6388\u4e88\u6743\u9650\u7684\u7528\u6237\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5237\u65b0\u6743\u9650<\/strong><\/p>\n<ul>\n<li>\u4e3a\u4e86\u4f7f\u6743\u9650\u66f4\u6539\u751f\u6548\uff0c\u8bf7\u4f7f\u7528 FLUSH PRIVILEGES \u8bed\u53e5\u5237\u65b0\u6743\u9650\u8868\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u8fde\u63a5\u5230\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u65b0\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n<pre>mysql -u new_user -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8f93\u5165\u5bc6\u7801\uff0c\u7136\u540e\u6309 Enter \u952e\u3002<\/li>\n<\/ul>\n<p>\u73b0\u5728\uff0c\u7528\u6237 new_user \u62e5\u6709\u5bf9\u6307\u5b9a\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\uff0c\u5e76\u53ef\u4ee5\u6267\u884c\u6388\u4e88\u7684\u6743\u9650\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u83b7\u5f97\u6743\u9650\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\u83b7\u5f97 mysql \u6743\u9650\uff0c\u9700\u8981\u521b\u5efa\u7528\u6237\u3001\u6388\u4e88\u6743\u9650\u3001\u5237\u65b0\u6743\u9650\u5e76\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a\u521b\u5efa\u7528\u6237\uff1a\u4f7f\u7528 create user \u8bed\u53e5\u5e76\u6307\u5b9a\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u6388\u4e88\u6743\u9650\uff1a\u4f7f\u7528 grant \u8bed\u53e5\u6388\u4e88\u7279\u5b9a\u6570\u636e\u5e93\u6216\u8868\u7684\u6743\u9650\u3002\u5237\u65b0\u6743\u9650\uff1a\u4f7f\u7528 flush privileges \u8bed\u53e5\u66f4\u65b0\u6743\u9650\u8868\u3002\u8fde\u63a5\u6570\u636e\u5e93\uff1a\u4f7f\u7528\u65b0\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002 \u5982\u4f55\u83b7\u5f97 MySQL \u6743\u9650 \u8981\u83b7\u5f97 MySQL \u6570\u636e\u5e93\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a 1. \u521b\u5efa\u7528\u6237 \u4f7f\u7528 CREATE USER \u8bed\u53e5\u521b\u5efa\u65b0\u7528\u6237\u3002\u4f8b\u5982\uff1a CREATE USER &#8216;new_user&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;password&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5c06 &#8216;new_user&#8217; \u66ff\u6362\u4e3a\u60a8\u8981\u521b\u5efa\u7684\u7528\u6237\u540d\u3002 \u5c06 &#8216;password&#8217; \u66ff\u6362\u4e3a\u7528\u6237\u5bc6\u7801\u3002 &#8216;%&#8217; \u8868\u793a\u5141\u8bb8\u7528\u6237\u4ece\u4efb\u4f55\u4e3b\u673a\u8bbf\u95ee\u6570\u636e\u5e93\u3002 2. \u6388\u4e88\u6743\u9650 \u4f7f\u7528 GRANT \u8bed\u53e5\u6388\u4e88\u7528\u6237\u5bf9\u7279\u5b9a\u6570\u636e\u5e93\u6216\u8868\u7684\u6743\u9650\u3002\u4f8b\u5982\uff1a GRANT ALL PRIVILEGES ON database_name.* TO &#8216;new_user&#8217;@&#8217;%&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5c06 database_name \u66ff\u6362\u4e3a\u8981\u6388\u4e88\u6743\u9650\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002 ALL [&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-5245","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5245","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=5245"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5245\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}