{"id":829,"date":"2024-09-11T11:03:16","date_gmt":"2024-09-11T03:03:16","guid":{"rendered":"https:\/\/thereisno.top\/?p=829"},"modified":"2024-10-22T15:30:11","modified_gmt":"2024-10-22T07:30:11","slug":"mysql%e5%8f%96%e6%b6%88%e6%9d%83%e9%99%90%e5%92%8c%e5%88%a0%e9%99%a4%e7%94%a8%e6%88%b7","status":"publish","type":"post","link":"https:\/\/thereisno.top\/?p=829","title":{"rendered":"mysql\u53d6\u6d88\u6743\u9650\u548c\u5220\u9664\u7528\u6237"},"content":{"rendered":"\n<p>\u4f5c\u4e3a\u6570\u636e\u5e93\u7684\u7ba1\u7406\u5458\uff0c\u65e2\u7136\u80fd\u591f\u521b\u5efa\u7528\u6237\u548c\u6388\u6743\uff0c\u540c\u6837\u4e5f\u53ef\u4ee5\u53d6\u6d88\u6388\u6743\u548c\u5220\u9664\u7528\u6237\u3002\u8981\u53d6\u6d88\u67d0\u4e2a\u7528\u6237\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528REVOKE\u8bed\u53e5\u3002\u8be5\u8bed\u53e5\u7684\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>&nbsp;Revoke privileges (columns) on what from user ;<\/p>\n\n\n\n<p>&nbsp;\u5176\u4e2dprivileges\u662f\u8981\u53d6\u6d88\u7684\u6743\u9650\uff0cuser\u662f\u8981\u88ab\u53d6\u6d88\u6743\u9650\u7684\u7528\u6237\u540d\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u5b9e\u73b0\u4e86\u53d6\u6d88sss\u7528\u6237\u7684\u6240\u6709\u6743\u9650\u7684\u529f\u80fd\u3002<\/p>\n\n\n\n<p>&nbsp;mysql&gt; revoke all on *.* from sss@localhost ;<\/p>\n\n\n\n<p>&nbsp;Query OK, 0 rows affected (0.00 sec)<\/p>\n\n\n\n<p>&nbsp;REVOKE\u8bed\u53e5\u53ea\u80fd\u53d6\u6d88\u7528\u6237\u7684\u6743\u9650\uff0c\u800c\u4e0d\u53ef\u4ee5\u5220\u9664\u7528\u6237\u3002\u5373\u4f7f\u53d6\u6d88\u4e86\u6240\u6709\u7684\u6743\u9650\uff0c\u7528\u6237\u4ecd\u7136\u53ef\u4ee5\u8fde\u63a5\u5230\u670d\u52a1\u5668\u3002\u8981\u60f3\u5f7b\u5e95\u7684\u5220\u9664\u7528\u6237\uff0c\u5fc5\u987b\u4f7f\u7528DELETE\u8bed\u53e5\u5c06\u8be5\u7528\u6237\u7684\u8bb0\u5f55\u4eceMySQL\u6570\u636e\u5e93\u4e2d\u7684user\u8868\u4e2d\u5220\u9664\u3002\u8be5\u8bed\u53e5\u7684\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>&nbsp;Delete from user where user = &#8220;user_name&#8221; and host = &#8220;host_name&#8221; ;<\/p>\n\n\n\n<p>&nbsp;\u4f7f\u7528DELETE\u5220\u9664\u7528\u6237sss\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>&nbsp;mysql&gt; use mysql<\/p>\n\n\n\n<p>&nbsp;Database changed<\/p>\n\n\n\n<p>&nbsp;mysql&gt; delete from user where user=&#8217;sss&#8217; and host=&#8217;localhost&#8217; ;<\/p>\n\n\n\n<p>&nbsp;mysql&gt;flush privileges ;<\/p>\n\n\n\n<p>&nbsp;Query OK, 1 row affected (0.02 sec)<\/p>\n\n\n\n<p>&nbsp;\u5176\u4e2d\uff0cdelete\u7528\u4e8e\u5220\u9664\u7528\u6237\uff0cflush\u544a\u8bc9\u670d\u52a1\u5668\u91cd\u65b0\u52a0\u8f7d\u6388\u6743\u8868\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u901a\u914d\u7b26\u6388\u6743\u6743\u9650<\/p>\n\n\n\n<p>Grant \u6743\u9650 on \u5e93.\u8868 to user@[localhost\/192.168.1.200\/192.168.1.%\/%] identified by &#8220;\u5bc6\u7801&#8221;<\/p>\n\n\n\n<p><strong>\u67e5\u770b\u7528\u6237&amp;\u6743\u9650<\/strong><\/p>\n\n\n\n<p>??\u4e3a\u4e86\u66f4\u597d\u7684\u5b9e\u8df5\uff0c\u5f53\u7136\u5148\u5f97\u544a\u8bc9\u4f60\u600e\u4e48\u67e5\u770b\u7528\u6237\u4fe1\u606f\u53ca\u7528\u6237\u6743\u9650\u3002<\/p>\n\n\n\n<p>??\u9996\u5148\u4f60\u5f97\u5728\u9ed1\u7a97\u53e3\u4e2d\u4f7f\u7528mysql -u root -p\u767b\u9646\u7ba1\u7406\u5458\u7528\u6237\u3002<\/p>\n\n\n\n<p><strong>\u67e5\u770b\u7528\u6237\u4fe1\u606f<\/strong><\/p>\n\n\n\n<p>use mysql; <\/p>\n\n\n\n<p><strong>select <\/strong>host,user,<strong>password<\/strong> <strong>from<\/strong> user;<\/p>\n\n\n\n<p>\u8fd9\u91cc\u7684host\u662f\u6307\u7528\u6237\u53ef\u4ee5\u5728\u54ea\u91cc\uff08\u54ea\u4e2aip\uff09\u767b\u9646\u5230\u8be5my<a href=\"https:\/\/www.2cto.com\/database\/\">sql\u6570\u636e\u5e93<\/a>\u3002localhost\u6216\u8005127.0.0.1\u8868\u793a\u672c\u5730\uff0c\u2019%\u2019\u8868\u793a\u6240\u6709ip\uff0c\u5176\u4ed6\u56fa\u5b9aip\u8fd9\u8868\u793a\u4ec5\u80fd\u901a\u8fc7\u90a3\u4e2aip\u3002\u4e0b\u9762\u4e3b\u8981\u5bf9\u672c\u5730\u7528\u6237\u8fdb\u884c\u8bf4\u660e\uff0c\u53ea\u8981\u5c06localhost\u6362\u6210\u76f8\u5e94ip\u6216\u8005\u2019%\u2019\u5373\u53ef\u8868\u793a\u8fdc\u7a0b\u7528\u6237\u3002<\/p>\n\n\n\n<p><strong>\u67e5\u770b\u7528\u6237\u6743\u9650<\/strong><\/p>\n\n\n\n<p>&#8212; \u67e5\u770b\u672c\u5730root\u7684\u6743\u9650\uff0c\u6ca1\u6709\u6307\u5b9a\u540e\u9762\u7684localhost\u5219\u9ed8\u8ba4\u4e3a&#8217;%&#8217; <\/p>\n\n\n\n<p>show grants <strong>for<\/strong> root@&#8217;localhost&#8217;; <\/p>\n\n\n\n<p>&#8212; \u67e5\u770b\u6307\u5b9ahost\u7684root\u7684\u6743\u9650 <\/p>\n\n\n\n<p>show grants <strong>for<\/strong> root@&#8217;192.168.122.12&#8242;;<\/p>\n\n\n\n<p><strong>\u521b\u5efa\u7528\u6237<\/strong><\/p>\n\n\n\n<p><strong>\u521b\u5efa\u672c\u5730\u7528\u6237<\/strong><\/p>\n\n\n\n<p>&#8212; \u9009\u62e9mysql\u6570\u636e\u5e93 <\/p>\n\n\n\n<p>use mysql; <\/p>\n\n\n\n<p>&#8212; \u521b\u5efa\u672c\u5730\u7528\u6237 <\/p>\n\n\n\n<p><strong>create <\/strong>user &#8216;superboy&#8217;@&#8217;localhost&#8217; identified <strong>by<\/strong> &#8216;iamsuperboy&#8217;; <\/p>\n\n\n\n<p>&#8212; \u5237\u65b0MySQL\u7684\u7cfb\u7edf\u6743\u9650\u76f8\u5173\u8868\uff0c\u4f7f\u6dfb\u52a0\u7528\u6237\u64cd\u4f5c\u751f\u6548\uff0c\u4ee5\u514d\u4f1a\u51fa\u73b0\u62d2\u7edd\u8bbf\u95ee <\/p>\n\n\n\n<p>flush <strong>privileges<\/strong>;<\/p>\n\n\n\n<p><strong>\u521b\u5efa\u8fdc\u7a0b\u7528\u6237<\/strong><\/p>\n\n\n\n<p>&#8212; \u4ece192.168.122.12\u767b\u9646\u7684\u7528\u6237 <\/p>\n\n\n\n<p><strong>create <\/strong>user &#8216;superboy&#8217;@&#8217;192.168.122.12&#8217; identified <strong>by<\/strong> &#8216;iamsuperboy&#8217;; <\/p>\n\n\n\n<p>&#8212; \u4ece\u4efb\u610fip\u767b\u9646\u7684\u7528\u6237 <\/p>\n\n\n\n<p><strong>create <\/strong>user &#8216;superboy&#8217;@&#8217;%&#8217; identified <strong>by<\/strong> &#8216;iamsuperboy&#8217;; <\/p>\n\n\n\n<p>&#8212; \u4e0d\u505a\u6307\u5b9a\u9ed8\u8ba4\u4e3a&#8217;%&#8217; <\/p>\n\n\n\n<p><strong>create <\/strong>user &#8216;superboy&#8217; identified <strong>by<\/strong> &#8216;iamsuperboy&#8217;;<\/p>\n\n\n\n<p><strong>\u4fee\u6539\u7528\u6237\u5bc6\u7801<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u9a6c\u5927\u54c8\u7684\u5c0f\u4f19\u4f34\u4e0d\u5c0f\u5fc3\u8f93\u9519\u4e86\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\u8fdb\u884c\u6551\u6025\u3002\u8fd9\u91cc\u6211\u4eec\u5c06\u5bc6\u7801\u2019iamsuperboy\u2019\u4fee\u6539\u4e3a\u2019iamsuperman\u2019\u3002<\/p>\n\n\n\n<p>&#8212; \u4f7f\u7528update\u6307\u4ee4\uff0c\u6ce8\u610f\u8fd9\u91cc\u7684password\u9700\u8981\u8fdb\u884c\u52a0\u5bc6 <\/p>\n\n\n\n<p>use mysql; <\/p>\n\n\n\n<p><strong>update <\/strong>user <strong>set<\/strong> <strong>password<\/strong> = <strong>password<\/strong>(&#8216;iamsuperman&#8217;) <strong>where<\/strong> user = &#8216;superboy&#8217;; <\/p>\n\n\n\n<p>flush <strong>privileges<\/strong>; <\/p>\n\n\n\n<p>&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u6216\u8005&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <\/p>\n\n\n\n<p><strong>set password<\/strong> <strong>for<\/strong> superboy@&#8217;localhost&#8217;= <strong>password<\/strong>(&#8216;iamsuperman&#8217;); <\/p>\n\n\n\n<p>flush <strong>privileges<\/strong>;<\/p>\n\n\n\n<p><strong>\u5220\u9664\u7528\u6237<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u9700\u8981\u5220\u9664\u7528\u6237\uff0c\u53ef\u4ee5\u8fd9\u6837\uff1a<\/p>\n\n\n\n<p>use mysql; <\/p>\n\n\n\n<p><strong>delete from<\/strong> user <strong>where<\/strong> user=&#8217;superboy&#8217; and host=&#8217;localhost&#8217; ; <\/p>\n\n\n\n<p>flush <strong>privileges<\/strong>;<\/p>\n\n\n\n<p>\u6ce8\u610f\uff1a\u521b\u5efa\u7528\u6237\u6216\u8005\u4fee\u6539\u7528\u6237\u5bc6\u7801\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u6267\u884c\u6307\u4ee4flush privileges;\u5237\u65b0MySQL\u7684\u7cfb\u7edf\u6743\u9650\u76f8\u5173\u8868\uff0c\u4f7f\u64cd\u4f5c\u751f\u6548\uff0c\u4ee5\u514d\u51fa\u73b0\u62d2\u7edd\u8bbf\u95ee\u3002<\/p>\n\n\n\n<p><strong>\u8d4b\u4e88&amp;\u64a4\u9500\u7528\u6237\u6743\u9650<\/strong><\/p>\n\n\n\n<p><strong>\u8d4b\u4e88\u7528\u6237\u6743\u9650<\/strong><\/p>\n\n\n\n<p>\u7531\u4e8e\u6211\u4eec\u7684\u9879\u76ee\uff0c\u7528\u6237\u53ea\u5bf9\u6570\u636e\u5e93\u2019simpleshop\u2019\u8fdb\u884c\u589e\u5220\u67e5\u6539\u64cd\u4f5c\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u589e\u5220\u67e5\u6539\u6743\u9650\u7684\u7528\u6237\u3002<\/p>\n\n\n\n<p>&#8212; \u8d4b\u4e88\u90e8\u5206\u6743\u9650\uff0c\u5176\u4e2d\u7684shopping.*\u8868\u793a\u5bf9\u4ee5shopping\u6240\u6709\u6587\u4ef6\u64cd\u4f5c\u3002 <\/p>\n\n\n\n<p><strong>grant select<\/strong>,<strong>delete<\/strong>,<strong>update<\/strong>,<strong>insert<\/strong> <strong>on<\/strong> simpleshop.* <strong>to<\/strong> superboy@&#8217;localhost&#8217; identified <strong>by<\/strong> &#8216;superboy&#8217;; <\/p>\n\n\n\n<p>flush <strong>privileges<\/strong>; <\/p>\n\n\n\n<p>&#8212; \u8d4b\u4e88\u6240\u6709\u6743\u9650 <\/p>\n\n\n\n<p><strong>grant <\/strong>all <strong>privileges<\/strong> <strong>on<\/strong> simpleshop.* <strong>to<\/strong> superboy@localhost identified <strong>by<\/strong> &#8216;iamsuperboy&#8217;; <\/p>\n\n\n\n<p>flush <strong>privileges<\/strong>;<\/p>\n\n\n\n<p><strong>\u64a4\u9500\u7528\u6237\u6743\u9650<\/strong><\/p>\n\n\n\n<p>\u540e\u6765\u6211\u4eec\u53d1\u73b0\uff0c\u6211\u4eec\u7684\u9879\u76ee\uff0c\u7528\u6237\u6839\u672c\u5c31\u4e0d\u9700\u8981\u4fee\u6539\u4fe1\u606f\u3002\u8fd9\u65f6\u6211\u4eec\u53ef\u4ee5\u64a4\u9500superboy\u7684update\u6743\u9650\u3002<\/p>\n\n\n\n<p>&#8212; \u64a4\u9500update\u6743\u9650 <\/p>\n\n\n\n<p><strong>revoke update<\/strong> <strong>on<\/strong> simpleshop.* <strong>from<\/strong> superboy@localhost; <\/p>\n\n\n\n<p>&#8212; \u64a4\u9500\u6240\u6709\u6743\u9650 <\/p>\n\n\n\n<p><strong>revoke <\/strong>all <strong>on<\/strong> simpleshop.* <strong>from<\/strong> superboy@localhost;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u6570\u636e\u5e93\u7684\u7ba1\u7406\u5458\uff0c\u65e2\u7136\u80fd\u591f\u521b\u5efa\u7528\u6237\u548c\u6388\u6743\uff0c\u540c\u6837\u4e5f\u53ef\u4ee5\u53d6\u6d88\u6388\u6743\u548c\u5220\u9664\u7528\u6237\u3002\u8981\u53d6\u6d88\u67d0\u4e2a\u7528\u6237\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528REV &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/thereisno.top\/?p=829\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cmysql\u53d6\u6d88\u6743\u9650\u548c\u5220\u9664\u7528\u6237\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[68],"class_list":["post-829","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=829"}],"version-history":[{"count":2,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/829\/revisions"}],"predecessor-version":[{"id":1304,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/829\/revisions\/1304"}],"wp:attachment":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}