{"id":5788,"date":"2024-11-14T08:44:12","date_gmt":"2024-11-14T00:44:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5788\/"},"modified":"2024-11-14T08:44:12","modified_gmt":"2024-11-14T00:44:12","slug":"mysql%e6%8e%88%e6%9d%83%e6%80%8e%e4%b9%88%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5788\/","title":{"rendered":"mysql\u6388\u6743\u600e\u4e48\u7528"},"content":{"rendered":"<blockquote><p>\n  \u6388\u6743\u5728 mysql \u4e2d\u662f\u6307\u6388\u4e88\u5176\u4ed6\u7528\u6237\u8bbf\u95ee\u6570\u636e\u5e93\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u901a\u8fc7 grant \u8bed\u53e5\u6388\u4e88\u3002\u8bed\u6cd5\u4e3a\uff1agrant on to [with grant option]\u3002\u5e38\u89c1\u7684\u6388\u6743\u793a\u4f8b\u5305\u62ec\u6388\u4e88\u9009\u62e9\u6570\u636e\u7684\u6743\u9650\uff1agrant select on my_database.* to alice;\u6388\u4e88\u63d2\u5165\u548c\u66f4\u65b0\u6570\u636e\u7684\u6743\u9650\u5e76\u5141\u8bb8\u59d4\u6d3e\uff1agrant insert, update on my_database.my_table to bob with gran\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/02\/2024060201304676527.jpg\" class=\"aligncenter\" title=\"mysql\u6388\u6743\u600e\u4e48\u7528\u63d2\u56fe\" alt=\"mysql\u6388\u6743\u600e\u4e48\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u6388\u6743\u6307\u5357<\/strong><\/p>\n<p><strong>\u6388\u6743\u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\n<p>\u6388\u6743\u662f\u6307\u6388\u4e88\u5176\u4ed6\u7528\u6237\u8bbf\u95ee\u548c\u64cd\u4f5c MySQL \u6570\u636e\u5e93\u7684\u6743\u9650\u3002<\/p>\n<p><strong>\u5982\u4f55\u6388\u6743\uff1f<\/strong><\/p>\n<p>\u4f7f\u7528 MySQL \u7684 GRANT \u8bed\u53e5\u53ef\u4ee5\u6388\u4e88\u6388\u6743\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>GRANT &lt;\u6743\u9650&gt; ON &lt;\u5bf9\u8c61&gt; TO &lt;\u7528\u6237&gt; [WITH GRANT OPTION]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>\uff1a\u8981\u6388\u4e88\u7684\u6743\u9650\uff0c\u4f8b\u5982 SELECT, INSERT, UPDATE, DELETE \u7b49\u3002<\/li>\n<li>\uff1a\u8981\u6388\u4e88\u6743\u9650\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u3001\u8868\u3001\u89c6\u56fe\u6216\u8fc7\u7a0b\u3002<\/li>\n<li>\uff1a\u8981\u6388\u4e88\u6743\u9650\u7684\u7528\u6237\u6216\u7ec4\u3002<\/li>\n<li>[WITH GRANT OPTION]\uff1a\u6388\u4e88\u7528\u6237\u5c06\u8be5\u6743\u9650\u8fdb\u4e00\u6b65\u59d4\u6d3e\u7ed9\u5176\u4ed6\u7528\u6237\u7684\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><strong>\u5e38\u89c1\u6388\u6743\u793a\u4f8b<\/strong><\/p>\n<ul>\n<li>\u6388\u4e88\u7528\u6237 alice \u5728\u6570\u636e\u5e93 my_database \u4e2d\u9009\u62e9\u6570\u636e\u7684\u6743\u9650\uff1a<\/li>\n<\/ul>\n<pre>GRANT SELECT ON my_database.* TO alice;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u6388\u4e88\u7528\u6237 bob \u5728\u8868 my_table \u4e2d\u63d2\u5165\u548c\u66f4\u65b0\u6570\u636e\u7684\u6743\u9650\uff0c\u5e76\u5141\u8bb8\u4ed6\u5c06\u8fd9\u4e9b\u6743\u9650\u59d4\u6d3e\u7ed9\u5176\u4ed6\u4eba\uff1a<\/li>\n<\/ul>\n<pre>GRANT INSERT, UPDATE ON my_database.my_table TO bob WITH GRANT OPTION;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u64a4\u9500\u6388\u6743<\/strong><\/p>\n<p>\u8981\u64a4\u9500\u6388\u6743\uff0c\u53ef\u4ee5\u4f7f\u7528 REVOKE \u8bed\u53e5\uff1a<\/p>\n<pre>REVOKE &lt;\u6743\u9650&gt; ON &lt;\u5bf9\u8c61&gt; FROM &lt;\u7528\u6237&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6700\u4f73\u5b9e\u8df5<\/strong><\/p>\n<ul>\n<li>\u9075\u5faa\u6700\u5c0f\u6743\u9650\u539f\u5219\uff0c\u4ec5\u6388\u4e88\u7528\u6237\u4ed6\u4eec\u6240\u9700\u8981\u7684\u6743\u9650\u3002<\/li>\n<li>\u4f7f\u7528\u89d2\u8272\u6765\u7ba1\u7406\u6743\u9650\uff0c\u8fd9\u6837\u53ef\u4ee5\u8f7b\u677e\u5730\u6388\u4e88\u548c\u64a4\u9500\u5bf9\u591a\u4e2a\u5bf9\u8c61\u7684\u6743\u9650\u3002<\/li>\n<li>\u5b9a\u671f\u5ba1\u6838\u6388\u6743\uff0c\u4ee5\u786e\u4fdd\u5b83\u4eec\u662f\u6700\u65b0\u7684\u4e14\u5b89\u5168\u7684\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6388\u6743\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>\u6388\u6743\u5728 mysql \u4e2d\u662f\u6307\u6388\u4e88\u5176\u4ed6\u7528\u6237\u8bbf\u95ee\u6570\u636e\u5e93\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u901a\u8fc7 grant \u8bed\u53e5\u6388\u4e88\u3002\u8bed\u6cd5\u4e3a\uff1agrant on to [with grant option]\u3002\u5e38\u89c1\u7684\u6388\u6743\u793a\u4f8b\u5305\u62ec\u6388\u4e88\u9009\u62e9\u6570\u636e\u7684\u6743\u9650\uff1agrant select on my_database.* to alice;\u6388\u4e88\u63d2\u5165\u548c\u66f4\u65b0\u6570\u636e\u7684\u6743\u9650\u5e76\u5141\u8bb8\u59d4\u6d3e\uff1agrant insert, update on my_database.my_table to bob with gran MySQL \u6388\u6743\u6307\u5357 \u6388\u6743\u662f\u4ec0\u4e48\uff1f \u6388\u6743\u662f\u6307\u6388\u4e88\u5176\u4ed6\u7528\u6237\u8bbf\u95ee\u548c\u64cd\u4f5c MySQL \u6570\u636e\u5e93\u7684\u6743\u9650\u3002 \u5982\u4f55\u6388\u6743\uff1f \u4f7f\u7528 MySQL \u7684 GRANT \u8bed\u53e5\u53ef\u4ee5\u6388\u4e88\u6388\u6743\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a GRANT &lt;\u6743\u9650&gt; ON &lt;\u5bf9\u8c61&gt; TO &lt;\u7528\u6237&gt; [WITH GRANT OPTION] \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a \uff1a\u8981\u6388\u4e88\u7684\u6743\u9650\uff0c\u4f8b\u5982 SELECT, INSERT, UPDATE, DELETE \u7b49\u3002 \uff1a\u8981\u6388\u4e88\u6743\u9650\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u3001\u8868\u3001\u89c6\u56fe\u6216\u8fc7\u7a0b\u3002 \uff1a\u8981\u6388\u4e88\u6743\u9650\u7684\u7528\u6237\u6216\u7ec4\u3002 [WITH [&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-5788","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5788","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=5788"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5788\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}