{"id":107739,"date":"2024-10-21T11:19:09","date_gmt":"2024-10-21T03:19:09","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=107739"},"modified":"2024-10-21T11:19:09","modified_gmt":"2024-10-21T03:19:09","slug":"grant-permissions-mysql","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/grant-permissions-mysql.html","title":{"rendered":"\u521b\u5efa\u65b0\u7528\u6237\u548c\u6388\u4e88MySQL\u4e2d\u7684\u6743\u9650\u6559\u7a0b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nMySQL\u662f\u4e00\u4e2a\u5f00\u6e90\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\uff0c\u53ef\u5e2e\u52a9\u7528\u6237\u5b58\u50a8\uff0c\u7ec4\u7ec7\u548c\u4ee5\u540e\u68c0\u7d22\u6570\u636e\u3002 \u5b83\u6709\u591a\u79cd\u9009\u9879\u6765\u6388\u4e88\u7279\u5b9a\u7528\u6237\u5728\u8868\u548c\u6570\u636e\u5e93\u4e2d\u7684\u7ec6\u5fae\u7684\u6743\u9650 - \u672c\u6559\u7a0b\u5c06\u7b80\u8981\u4ecb\u7ecd\u4e00\u4e9b\u9009\u9879\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5982\u4f55\u521b\u5efa\u65b0\u7528\u6237<\/strong><\/span><\/div>\n

\u5728MySQL\u7684\u6559\u7a0b\u7684\u7b2c1\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u505a\u4e86\u6240\u6709\u5728MySQL\u4e2d\u7f16\u8f91root\u7528\u6237\uff0c\u62e5\u6709\u5b8c\u5168\u8bbf\u95ee\u6240\u6709\u7684\u6570\u636e\u5e93\u3002 \u4f46\u662f\uff0c\u5728\u53ef\u80fd\u9700\u8981\u66f4\u591a\u9650\u5236\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u81ea\u5b9a\u4e49\u6743\u9650\u521b\u5efa\u7528\u6237\u3002<\/p>\n

\u8ba9\u6211\u4eec\u4ece\u5728MySQL shell\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237\u5f00\u59cb\uff1a<\/p>\n

\r\nCREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';\r\n<\/pre>\n

\u53ef\u60b2\u7684\u662f\uff0c\u6b64\u65f6newuser\u6ca1\u6709\u6743\u9650\u5bf9\u6570\u636e\u5e93\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\u3002 \u4e8b\u5b9e\u4e0a\uff0c\u5982\u679cnewuser\u751a\u81f3\u5c1d\u8bd5\u767b\u5f55\uff08\u4f7f\u7528\u5bc6\u7801\uff0c\u5bc6\u7801\uff09\uff0c\u4ed6\u4eec\u5c06\u65e0\u6cd5\u8bbf\u95eeMySQL shell\u3002<\/p>\n

\u56e0\u6b64\uff0c\u9996\u5148\u8981\u505a\u7684\u662f\u4e3a\u7528\u6237\u63d0\u4f9b\u8bbf\u95ee\u4ed6\u4eec\u5c06\u9700\u8981\u7684\u4fe1\u606f\u7684\u6743\u9650\u3002<\/p>\n

\r\nGRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';\r\n<\/pre>\n

\u6b64\u547d\u4ee4\u4e2d\u7684\u661f\u53f7\u5206\u522b\u8868\u793a\u5b83\u4eec\u53ef\u4ee5\u8bbf\u95ee\u7684\u6570\u636e\u5e93\u548c\u8868\uff08\u8fd9\u4e9b\u547d\u4ee4\u5141\u8bb8\u7528\u6237\u5728\u6240\u6709\u6570\u636e\u5e93\u548c\u8868\u4e2d\u8bfb\u53d6\uff0c\u7f16\u8f91\uff0c\u6267\u884c\u548c\u6267\u884c\u6240\u6709\u4efb\u52a1\uff09\u3002<\/p>\n

\u4e00\u65e6\u60a8\u786e\u5b9a\u4e86\u8981\u4e3a\u65b0\u7528\u6237\u8bbe\u7f6e\u7684\u6743\u9650\uff0c\u8bf7\u52a1\u5fc5\u91cd\u65b0\u52a0\u8f7d\u6240\u6709\u6743\u9650\u3002<\/p>\n

\r\nFLUSH PRIVILEGES;\r\n<\/pre>\n

\u60a8\u7684\u66f4\u6539\u73b0\u5df2\u751f\u6548\u3002<\/p>\n

\u5982\u4f55\u6388\u4e88\u4e0d\u540c\u7684\u7528\u6237\u6743\u9650<\/strong><\/span><\/div>\n

\u4ee5\u4e0b\u662f\u7528\u6237\u53ef\u4ee5\u4eab\u53d7\u7684\u5176\u4ed6\u5e38\u89c1\u53ef\u80fd\u6743\u9650\u7684\u7b80\u77ed\u5217\u8868\u3002<\/p>\n

\r\nALL PRIVILEGES - \u6b63\u5982\u6211\u4eec\u524d\u9762\u6240\u770b\u5230\u7684\uff0c\u8fd9\u5c06\u5141\u8bb8MySQL\u7528\u6237\u8bbf\u95ee\u6307\u5b9a\u7684\u6570\u636e\u5e93\uff08\u6216\u8005\u5982\u679c\u7cfb\u7edf\u4e2d\u6ca1\u6709\u9009\u62e9\u6570\u636e\u5e93\uff09\r\nCREATE-\u5141\u8bb8\u4ed6\u4eec\u521b\u5efa\u65b0\u7684\u8868\u6216\u6570\u636e\u5e93\r\nDROP-\u5141\u8bb8\u4ed6\u4eec\u5220\u9664\u8868\u6216\u6570\u636e\u5e93\r\nDELETE-\u5141\u8bb8\u4ed6\u4eec\u4ece\u8868\u4e2d\u5220\u9664\u884c\r\nINSERT-\u5141\u8bb8\u5b83\u4eec\u5411\u8868\u4e2d\u63d2\u5165\u884c\r\nSELECT-\u5141\u8bb8\u4ed6\u4eec\u4f7f\u7528Select\u547d\u4ee4\u6765\u8bfb\u53d6\u6570\u636e\u5e93\r\nUPDATE-\u5141\u8bb8\u4ed6\u4eec\u66f4\u65b0\u8868\u884c\r\nGRANT OPTION - \u5141\u8bb8\u4ed6\u4eec\u6388\u4e88\u6216\u5220\u9664\u5176\u4ed6\u7528\u6237\u7684\u6743\u9650\r\n<\/pre>\n

\u8981\u5411\u7279\u5b9a\u7528\u6237\u63d0\u4f9b\u6743\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b64\u6846\u67b6\uff1a<\/p>\n

\r\n GRANT [type of permission] ON [database name].[table \u201c\u201d not found \/]
\n TO \u2018[username]\u2019@'localhost\u2019;\r\n<\/pre>\n

\u5982\u679c\u8981\u5411\u5176\u6388\u4e88\u5bf9\u4efb\u4f55\u6570\u636e\u5e93\u6216\u4efb\u4f55\u8868\u7684\u8bbf\u95ee\u6743\u9650\uff0c\u8bf7\u786e\u4fdd\u5728\u6570\u636e\u5e93\u540d\u79f0\u6216\u8868\u540d\u79f0\u7684\u5730\u65b9\u653e\u7f6e\u661f\u53f7\uff08*\uff09\u3002<\/p>\n

\u6bcf\u6b21\u66f4\u65b0\u6216\u66f4\u6539\u6743\u9650\u65f6\uff0c\u8bf7\u52a1\u5fc5\u4f7f\u7528Flush Privileges\u547d\u4ee4\u3002<\/p>\n

\u5982\u679c\u60a8\u9700\u8981\u64a4\u6d88\u6743\u9650\uff0c\u5219\u7ed3\u6784\u4e0e\u6388\u4e88\u7684\u7ed3\u6784\u51e0\u4e4e\u76f8\u540c\uff1a<\/p>\n

\r\n REVOKE [type of permission] ON [database name].[table \u201c\u201d not found \/]
\n FROM \u2018[username]\u2019@\u2018localhost\u2019;\r\n<\/pre>\n

\u6b63\u5982\u60a8\u53ef\u4ee5\u4f7f\u7528DROP\u5220\u9664\u6570\u636e\u5e93\u4e00\u6837\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528DROP\u5b8c\u5168\u5220\u9664\u7528\u6237\uff1a<\/p>\n

\r\n DROP USER \u2018demo\u2019@\u2018localhost\u2019;\r\n<\/pre>\n

\u8981\u6d4b\u8bd5\u60a8\u7684\u65b0\u7528\u6237\uff0c\u8bf7\u901a\u8fc7\u952e\u5165\u6ce8\u9500<\/p>\n

\r\n quit \r\n<\/pre>\n

\u5e76\u4f7f\u7528\u6b64\u547d\u4ee4\u5728\u7ec8\u7aef\u4e2d\u91cd\u65b0\u767b\u5f55\uff1a<\/p>\n

\r\nmysql -u [username]-p\r\n<\/pre>\n
\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/www.howtoing.com\/how-to-create-a-new-user-and-grant-permissions-in-mysql<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/grant-permissions-mysql.html<\/a>\u7f16\u8f91\uff1a\u5434\u5411\u5e73\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb MySQL\u662f\u4e00\u4e2a\u5f00\u6e90\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\uff0c\u53ef\u5e2e\u52a9\u7528\u6237\u5b58\u50a8\uff0c\u7ec4\u7ec7\u548c\u4ee5\u540e\u68c0\u7d22\u6570\u636e\u3002 \u5b83\u6709\u591a\u79cd\u9009\u9879\u6765\u6388\u4e88\u7279\u5b9a\u7528\u6237\u5728\u8868 […]<\/p>\n","protected":false},"author":668,"featured_media":22768,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-107739","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/107739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=107739"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/107739\/revisions"}],"predecessor-version":[{"id":293764,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/107739\/revisions\/293764"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/22768"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=107739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=107739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=107739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}