{"id":180,"date":"2022-03-14T10:44:11","date_gmt":"2022-03-14T02:44:11","guid":{"rendered":"https:\/\/blog.lijiajia.top\/?p=180"},"modified":"2026-06-19T17:28:36","modified_gmt":"2026-06-19T09:28:36","slug":"mysql%e5%88%9b%e5%bb%ba%e7%94%a8%e6%88%b7-%e6%8e%88%e6%9d%83","status":"publish","type":"post","link":"https:\/\/blog.ttwow.top\/?p=180","title":{"rendered":"Mysql\u521b\u5efa\u7528\u6237 \u6388\u6743"},"content":{"rendered":"<p>\u57fa\u4e8emysql5.7<\/p>\n<h2>\u4e3a\u7528\u6237\u521b\u5efa\u6570\u636e\u5e93<\/h2>\n<pre><code class=\"language-sql\">create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;<\/code><\/pre>\n<h2>\u63a8\u8350\u5feb\u901f\u7528\u6237\u5e76\u8fdc\u7a0b\u8bbf\u95ee<\/h2>\n<pre><code class=\"language-sql\">GRANT ALL PRIVILEGES ON test.* TO &#039;test&#039;@&#039;%&#039; IDENTIFIED BY &#039;test&#039; WITH GRANT OPTION;\n#\u5237\u65b0\nflush privileges;<\/code><\/pre>\n<hr \/>\n<p>\u4ee5\u4e0b\u90fd\u662f\u5728root\u7528\u6237\u4e0b\u64cd\u4f5c<\/p>\n<h2>\u521b\u5efa\u7528\u6237<\/h2>\n<p>\u5373\u5c06user\u8868\u7684localhost\u6539\u4e3a%<\/p>\n<pre><code class=\"language-sql\">CREATE USER &#039;test&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test&#039;;<\/code><\/pre>\n<h2>\u67e5\u8be2\u7528\u6237<\/h2>\n<pre><code class=\"language-sql\">select user,host from mysql.user;<\/code><\/pre>\n<h2>\u5220\u9664\u7528\u6237<\/h2>\n<pre><code class=\"language-sql\">\u5224\u65ad\u6709\u6ca1\u6709\u5f00\u542f\u8fdc\u7a0b\u8bbf\u95ee\uff0c\u672c\u5730\u8bbf\u95ee\u4f7f\u7528\u4e0a\u9762\n\u8fdc\u7a0b\u8bbf\u95ee\u4f7f\u7528\u4e0b\u9762\u7684\u5220\u9664\nDROP USER &#039;test&#039;@&#039;localhost&#039;;\n\u6216\nDROP USER &#039;test&#039;@&#039;%&#039;;<\/code><\/pre>\n<h2>\u6388\u6743\u8fdc\u7a0b\u8bbf\u95ee<\/h2>\n<p>\u5373\u5c06host\u5b57\u6bb5localhost\u6539\u4e3a%<\/p>\n<pre><code class=\"language-sql\">update mysql.user set host = &#039;%&#039; where user = &#039;test&#039;;\nflush privileges;\n\n\u66b4\u529b\uff0c\u7ed9\u4e86\u6240\u6709\u5e93\u6240\u6709\u6743\u9650\uff0c\u5e76\u8fdc\u7a0b\u8bbf\u95ee\n\u4e0d\u63a8\u8350\uff0c\nGRANT ALL PRIVILEGES ON *.* TO &#039;test&#039;@&#039;%&#039; IDENTIFIED BY &#039;test&#039; WITH GRANT OPTION;\nflush privileges;<\/code><\/pre>\n<h2>\u67e5\u770b\u6743\u9650<\/h2>\n<pre><code class=\"language-sql\">show grants for test;<\/code><\/pre>\n<h2>\u6388\u6743<\/h2>\n<pre><code class=\"language-sql\">#\u6388\u6743 \u6240\u6709\u6743\u9650\nGRANT privileges ON \u6570\u636e\u5e93\u540d.\u8868\u540d TO &#039;\u7528\u6237\u540d&#039;@&#039;host&#039;\n#\u6388\u6743 \u90e8\u5206\u6743\u9650\ngrant select,insert,update,delete on gushici.* to \u7528\u6237\u540d@&quot;%&quot; identified by &quot;\u5bc6\u7801&quot;;<\/code><\/pre>\n<h2>\u4fee\u6539\u5bc6\u7801<\/h2>\n<pre><code class=\"language-sql\">#\u4fee\u6539root\u5bc6\u7801\nset password = password(&#039;\u5bc6\u7801&#039;);\nflush privileges;\n\n#\u4fee\u6539\u666e\u901a\u7528\u6237\u5bc6\u7801\nset password for \u7528\u6237\u540d@localhost = password(&#039;\u5bc6\u7801&#039;);\nflush privileges;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u4e8emysql5.7 \u4e3a\u7528\u6237\u521b\u5efa\u6570\u636e\u5e93 create database test DEFAULT CHARSE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[130],"tags":[58],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-linux-ops","tag-mysql"],"_links":{"self":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180"}],"version-history":[{"count":1,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":1992,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions\/1992"}],"wp:attachment":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}