{"id":481,"date":"2020-06-09T21:42:20","date_gmt":"2020-06-09T13:42:20","guid":{"rendered":"https:\/\/freeapp.sbs\/blog\/?p=481"},"modified":"2025-04-01T16:53:31","modified_gmt":"2025-04-01T07:53:31","slug":"awy2uvfzq4hugkf","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2020\/06\/09\/awy2uvfzq4hugkf\/","title":{"rendered":"\u66f4\u6539Docker\u5bb9\u5668\u4e2d\u7684Mysql\u6570\u636e\u5e93\u5bc6\u7801"},"content":{"rendered":"<p>\u66f4\u6539\u6570\u636e\u5e93\u5bc6\u7801\uff0c\u9700\u8981\u6570\u636e\u5e93\u7684\u521d\u59cb\u5bc6\u7801\u3002\u5bb9\u5668\u9996\u6b21\u542f\u52a8\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u5bc6\u7801\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u80fd\u591f\u67e5\u770b\u5230\u521d\u59cb\u5bc6\u7801\uff1a<\/p>\n<pre>docker logs Mysql\u6570\u636e\u5e93\u5bb9\u5668\u540d<\/pre>\n<p>\u5728\u65e5\u5fd7\u4e2d\u6709\u5bc6\u7801\u3002\u4f7f\u7528\u6539\u5bc6\u7801\u767b\u5f55\u5230\u6570\u636e\u5e93\uff0c\u66f4\u6539\u6570\u636e\u5e93\u5bc6\u7801\uff1a<\/p>\n<pre class=\"lang-sql prettyprint prettyprinted\"><code><span class=\"pln\">mysql<\/span><span class=\"pun\">&gt;<\/span> <span class=\"kwd\">update<\/span> <span class=\"kwd\">user<\/span> <span class=\"kwd\">set<\/span><span class=\"pln\"> authentication_string<\/span><span class=\"pun\">=<\/span><span class=\"pln\">password<\/span><span class=\"pun\">(<\/span><span class=\"str\">'new_password'<\/span><span class=\"pun\">)<\/span> <span class=\"kwd\">where<\/span> <span class=\"kwd\">user<\/span><span class=\"pun\">=<\/span><span class=\"str\">'root'<\/span><span class=\"pun\">;<\/span><\/code><\/pre>\n<p>\u6216\u8005<\/p>\n<pre class=\"lang-sql prettyprint prettyprinted\"><code><span class=\"pln\">mysql<\/span><span class=\"pun\">&gt;<\/span> <span class=\"kwd\">SET<\/span><span class=\"pln\"> PASSWORD <\/span><span class=\"kwd\">FOR<\/span> <span class=\"str\">'root'<\/span> <span class=\"pun\">=<\/span><span class=\"pln\"> PASSWORD<\/span><span class=\"pun\">(<\/span><span class=\"str\">'new_password'<\/span><span class=\"pun\">);<\/span><\/code><\/pre>\n<p>Mysql 5.7\u53ca\u4e4b\u524d\u7684\u7248\u672c\u4f7f\u7528\uff1a<\/p>\n<pre class=\"lang-sql prettyprint prettyprinted\"><code><span class=\"pln\">mysql<\/span><span class=\"pun\">&gt;<\/span> <span class=\"kwd\">ALTER<\/span> <span class=\"kwd\">USER<\/span> <span class=\"str\">'root'<\/span><span class=\"pun\">@<\/span><span class=\"str\">'localhost'<\/span><span class=\"pln\"> IDENTIFIED <\/span><span class=\"kwd\">BY<\/span> <span class=\"str\">'newpassword'<\/span><span class=\"pun\">;<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u4e0a\u9762\u7684\u547d\u4ee4\u4fee\u6539\u5b8c\u5bc6\u7801\uff0c\u4ecd\u7136\u53ea\u5141\u8bb8\u201croot\u201d\u4ece\u201clocalhost\u201d\u8fde\u63a5\uff0c\u82e5\u6539\u53d8\u5bc6\u7801\u5e76\u5141\u8bb8\u201croot\u201d\u4ece\u4efb\u610f\u4e3b\u673a\u767b\u5f55\uff0c\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff1a<\/p>\n<pre class=\"lang-sql prettyprint prettyprinted\"><code><span class=\"kwd\">ALTER<\/span> <span class=\"kwd\">USER<\/span> <span class=\"str\">'root'<\/span><span class=\"pun\">@<\/span><span class=\"str\">'%'<\/span><span class=\"pln\"> IDENTIFIED <\/span><span class=\"kwd\">BY<\/span> <span class=\"str\">'newpassword'<\/span><span class=\"pun\">;<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u66f4\u6539\u6570\u636e\u5e93\u5bc6\u7801\uff0c\u9700\u8981\u6570\u636e\u5e93\u7684\u521d\u59cb\u5bc6\u7801\u3002\u5bb9\u5668\u9996\u6b21\u542f\u52a8\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u5bc6\u7801\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u80fd\u591f\u67e5\u770b\u5230\u521d\u59cb\u5bc6\u7801\uff1a docker logs Mysql\u6570\u636e\u5e93\u5bb9\u5668\u540d \u5728\u65e5\u5fd7\u4e2d\u6709\u5bc6\u7801\u3002\u4f7f\u7528\u6539\u5bc6\u7801\u767b\u5f55\u5230\u6570\u636e\u5e93\uff0c\u66f4\u6539\u6570\u636e\u5e93\u5bc6\u7801\uff1a mysql&gt; update user set authentication_string=password(&#8216;new_password&#8217;) where user=&#8217;root&#8217;; \u6216\u8005 mysql&gt; SET PASSWORD FOR &#8216;root&#8217; = PASSWORD(&#8216;new_password&#8217;); Mysql 5.7\u53ca\u4e4b\u524d\u7684\u7248\u672c\u4f7f\u7528\uff1a mysql&gt; ALTER USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;newpassword&#8217;; &nbsp; \u4e0a\u9762\u7684\u547d\u4ee4\u4fee\u6539\u5b8c\u5bc6\u7801\uff0c\u4ecd\u7136\u53ea\u5141\u8bb8\u201croot\u201d\u4ece\u201clocalhost\u201d\u8fde\u63a5\uff0c\u82e5\u6539\u53d8\u5bc6\u7801\u5e76\u5141\u8bb8\u201croot\u201d\u4ece\u4efb\u610f\u4e3b\u673a\u767b\u5f55\uff0c\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff1a ALTER USER &#8216;root&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;newpassword&#8217;; &nbsp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[],"class_list":["post-481","post","type-post","status-publish","format-standard","hentry","category-y8behyrmw-2lc"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/comments?post=481"}],"version-history":[{"count":1,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":2237,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/481\/revisions\/2237"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}