{"id":7233,"date":"2024-11-14T12:53:07","date_gmt":"2024-11-14T04:53:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7233\/"},"modified":"2024-11-14T12:53:07","modified_gmt":"2024-11-14T04:53:07","slug":"%e8%bf%9c%e7%a8%8b%e6%95%b0%e6%8d%ae%e5%ba%93%e8%b4%a6%e6%88%b7%e5%88%9b%e5%bb%ba%e6%88%90%e5%8a%9f%e5%8d%b4%e6%97%a0%e6%b3%95%e8%bf%9e%e6%8e%a5%ef%bc%9ainit_connect-%e5%91%bd%e4%bb%a4%e5%bc%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7233\/","title":{"rendered":"\u8fdc\u7a0b\u6570\u636e\u5e93\u8d26\u6237\u521b\u5efa\u6210\u529f\u5374\u65e0\u6cd5\u8fde\u63a5\uff1ainit_connect \u547d\u4ee4\u5f15\u53f7\u5bfc\u81f4\u7684\u95ee\u9898"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173062605248780.jpg\" class=\"aligncenter\" title=\"\u8fdc\u7a0b\u6570\u636e\u5e93\u8d26\u6237\u521b\u5efa\u6210\u529f\u5374\u65e0\u6cd5\u8fde\u63a5\uff1ainit_connect \u547d\u4ee4\u5f15\u53f7\u5bfc\u81f4\u7684\u95ee\u9898\u63d2\u56fe\" alt=\"\u8fdc\u7a0b\u6570\u636e\u5e93\u8d26\u6237\u521b\u5efa\u6210\u529f\u5374\u65e0\u6cd5\u8fde\u63a5\uff1ainit_connect \u547d\u4ee4\u5f15\u53f7\u5bfc\u81f4\u7684\u95ee\u9898\u63d2\u56fe\" \/><\/p>\n<p><strong>\u521b\u5efa\u8fdc\u7a0b\u8bbf\u95ee\u6570\u636e\u5e93\u8d26\u6237\u5374\u65e0\u6cd5\u8fde\u63a5\uff0c\u539f\u56e0\u4f55\u5728\uff1f<\/strong><\/p>\n<p>\u95ee\u9898\u63cf\u8ff0\uff1a<\/p>\n<p>\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u7684 root \u7528\u6237\u53ef\u4ee5\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u4f46\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u521b\u5efa\u7684 auser \u7528\u6237\uff0c\u5374\u65e0\u6cd5\u8fdc\u7a0b\u767b\u5f55\u3002<\/p>\n<pre>create user 'auser'@'%' identified by 'auser';\ngrant all on `mydb`.* to 'auser'@'%';\nflush privileges;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728  \u4e2d\u767b\u5f55 auser \u8d26\u6237\u65f6\uff0c\u4f1a\u51fa\u73b0 2013 &#8211; lost connection to  server during query \u7684\u63d0\u793a\u3002<\/p>\n<p>\u95ee\u9898\u5206\u6790\uff1a<\/p>\n<p>\u4ee5 mysql \u547d\u4ee4\u767b\u5f55 auser \u8d26\u6237\u540e\u53d1\u73b0\uff0c\u63d0\u793a init_connect command fled\u3002\u5728\u7f51\u4e0a\u67e5\u9605\u540e\u53d1\u73b0\uff0c\u9700\u8981\u4fee\u6539 \/etc\/my.cnf \u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4e24\u884c\u7684 \u201c (\u53cc\u5f15\u53f7) \u6539\u4e3a &#8216; (\u5355\u5f15\u53f7)\u3002<\/p>\n<pre>init_connect=\u2018set collation_connection = utf8_unicode_ci\u2019\ninit_connect=\u2018set names utf8\u2019<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6539\u4e3a\uff1a<\/p>\n<pre>init_connect='SET collation_connection = utf8_unicode_ci'\ninit_connect='SET NAMES utf8'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u540e\u7eed\u64cd\u4f5c\uff1a<\/p>\n<p>\u5b8c\u6210\u540e\u91cd\u542f mysqld \u670d\u52a1\uff0c\u95ee\u9898\u89e3\u51b3\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8fdc\u7a0b\u6570\u636e\u5e93\u8d26\u6237\u521b\u5efa\u6210\u529f\u5374\u65e0\u6cd5\u8fde\u63a5\uff1ainit_connect \u547d\u4ee4\u5f15\u53f7\u5bfc\u81f4\u7684\u95ee\u9898\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>\u521b\u5efa\u8fdc\u7a0b\u8bbf\u95ee\u6570\u636e\u5e93\u8d26\u6237\u5374\u65e0\u6cd5\u8fde\u63a5\uff0c\u539f\u56e0\u4f55\u5728\uff1f \u95ee\u9898\u63cf\u8ff0\uff1a \u8fdc\u7a0b\u4e3b\u673a\u4e0a\u7684 root \u7528\u6237\u53ef\u4ee5\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u4f46\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u521b\u5efa\u7684 auser \u7528\u6237\uff0c\u5374\u65e0\u6cd5\u8fdc\u7a0b\u767b\u5f55\u3002 create user &#8216;auser&#8217;@&#8217;%&#8217; identified by &#8216;auser&#8217;; grant all on `mydb`.* to &#8216;auser&#8217;@&#8217;%&#8217;; flush privileges; \u767b\u5f55\u540e\u590d\u5236 \u5728 \u4e2d\u767b\u5f55 auser \u8d26\u6237\u65f6\uff0c\u4f1a\u51fa\u73b0 2013 &#8211; lost connection to server during query \u7684\u63d0\u793a\u3002 \u95ee\u9898\u5206\u6790\uff1a \u4ee5 mysql \u547d\u4ee4\u767b\u5f55 auser \u8d26\u6237\u540e\u53d1\u73b0\uff0c\u63d0\u793a init_connect command fled\u3002\u5728\u7f51\u4e0a\u67e5\u9605\u540e\u53d1\u73b0\uff0c\u9700\u8981\u4fee\u6539 \/etc\/my.cnf \u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4e24\u884c\u7684 \u201c (\u53cc\u5f15\u53f7) \u6539\u4e3a &#8216; (\u5355\u5f15\u53f7)\u3002 init_connect=\u2018set collation_connection = utf8_unicode_ci\u2019 [&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-7233","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7233","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=7233"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7233\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}