{"id":628,"date":"2023-02-26T11:13:58","date_gmt":"2023-02-26T03:13:58","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=628"},"modified":"2023-04-29T20:15:59","modified_gmt":"2023-04-29T12:15:59","slug":"mysql-remote-connect-faqs","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/mysql-remote-connect-faqs\/","title":{"rendered":"MySQL\u8fdc\u7a0b\u8fde\u63a5\u5e38\u89c1\u95ee\u9898"},"content":{"rendered":"<blockquote>\n<p>\u6ce8\u610f\uff1a\u4e91\u670d\u52a1\u5668\u5b89\u5168\u7ec4\u89c4\u5219\u5141\u8bb83306\u7aef\u53e3\u8bbf\u95ee\uff08\u9632\u706b\u5899\u5141\u8bb83306\u7aef\u53e3\u8bbf\u95ee\uff09<\/p>\n<\/blockquote>\n<h4>*<em>Host <\/em> is not allowed to connect to this MySQL server**<\/h4>\n<p>\u4f7f\u7528root\u6743\u9650\u767b\u5165MySQL\uff0c\u66f4\u6539&quot;mysql&quot;\u6570\u636e\u5e93\u91cc\u7684&quot;user&quot;\u8868\u91cc\u7684&quot;Host&quot;\u5b57\u6bb5\uff0c\u4ece&quot;localhost&quot;\u6539\u4e3a&#8217;%&#8217;<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-shell\">$ mysql -u root -p\n>&gt; use mysql;\n>&gt; select * from `user`;\n>&gt; update `db` set `Host` = &#039;%&#039; where `db`.`Host` = &#039;localhost&#039; and `db`.`Db` = &#039;db-name&#039; and `db`.`User` = &#039;db-user&#039;;\n>&gt; update `db` set `Host` = &#039;%&#039; where `db`.`Host` = &#039;localhost&#039; and `db`.`Db` = &#039;db-name\\\\_%&#039; and `db`.`User` = &#039;db-user&#039;;\n>&gt; update `user` set `Host` = &#039;%&#039; where `user`.`Host` = &#039;localhost&#039; and `user`.`User` = &#039;db-user&#039;;\n>&gt; flush privileges;<\/code><\/pre>\n<ul>\n<li>db-user: \u6570\u636e\u5e93\u7528\u6237\u540d<\/li>\n<\/ul>\n<h4><strong>Access denied for user &#8216;db-user&#8217;@&#8217;%&#8217; to database &#8216;db-name&#8217;<\/strong><\/h4>\n<pre><code>grant all on db-name.* to &#039;db-user&#039;@&#039;%&#039; identified by &#039;db-password&#039; with grant option;<\/code><\/pre>\n<ul>\n<li>db-name: \u6570\u636e\u5e93\u540d\u79f0<\/li>\n<li>db-user: \u6570\u636e\u5e93\u6240\u5c5e\u7528\u6237<\/li>\n<li>db-password: \u6570\u636e\u5e93\u7528\u6237\u767b\u5f55\u5bc6\u7801<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6ce8\u610f\uff1a\u4e91\u670d\u52a1\u5668\u5b89\u5168\u7ec4\u89c4\u5219\u5141\u8bb83306\u7aef\u53e3\u8bbf\u95ee\uff08\u9632\u706b\u5899\u5141\u8bb83306\u7aef\u53e3\u8bbf\u95ee\uff09 *Host is not allo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-628","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=628"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/628\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}