{"id":6262,"date":"2024-11-14T08:43:11","date_gmt":"2024-11-14T00:43:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6262\/"},"modified":"2024-11-14T08:43:11","modified_gmt":"2024-11-14T00:43:11","slug":"mysql%e5%af%86%e7%a0%81%e5%bf%98%e4%ba%86%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6262\/","title":{"rendered":"mysql\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b"},"content":{"rendered":"<p>\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b\uff1f\u8fd9\u662f\u4e0d\u5c11\u7f51\u53cb\u90fd\u5173\u6ce8\u7684\u95ee\u9898\uff0c\u63a5\u4e0b\u6765\u7531php\u5c0f\u7f16\u4e3a\u5927\u5bb6\u5e26\u6765<strong>mysql\u5fd8\u8bb0\u5bc6\u7801\u67e5\u770b\u65b9\u6cd5<\/strong>\uff0c\u611f\u5174\u8da3\u7684\u7f51\u53cb\u4e00\u8d77\u968f\u5c0f\u7f16\u6765\u77a7\u77a7\u5427\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/18\/2024061813232024113.jpg\" class=\"aligncenter\" title=\"mysql\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b\u63d2\u56fe\" alt=\"mysql\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b\u63d2\u56fe\" \/><\/p>\n<h3>mysql\u5fd8\u8bb0\u5bc6\u7801\u67e5\u770b\u65b9\u6cd5<\/h3>\n<p>1\u3001\u9996\u5148\uff0c\u505c\u6b62MySQL\u670d\u52a1\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165sudo service mysql stop\u6765\u505c\u6b62MySQL\u670d\u52a1\u3002<\/p>\n<p>2\u3001\u63a5\u7740\uff0c\u4f7f\u7528\u4e00\u4e2a\u7279\u6b8a\u7684\u542f\u52a8\u53c2\u6570\u542f\u52a8MySQL\u670d\u52a1\uff0c\u8be5\u53c2\u6570\u5c06\u8df3\u8fc7\u6743\u9650\u68c0\u67e5\uff0c\u5141\u8bb8\u4f60\u767b\u5f55\u800c\u4e0d\u9700\u8981\u5bc6\u7801\u3002<\/p>\n<p>3\u3001\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165sudo mysqld_safe &#8211;skip-grant-tables &amp;\u6765\u542f\u52a8MySQL\u670d\u52a1\u3002\u7136\u540e\uff0c\u4f7f\u7528root\u7528\u6237\u767b\u5f55\u5230MySQL\u6570\u636e\u5e93\u3002<\/p>\n<p>4\u3001\u5728\u547d\u4ee4\u884c\u8f93\u5165mysql -u root\uff0c\u7136\u540e\u6309Enter\u952e\u3002\u5728MySQL\u63d0\u793a\u7b26\u4e0b\uff0c\u5207\u6362\u5230mysql\u6570\u636e\u5e93\u3002\u8f93\u5165use mysql;\uff0c\u7136\u540e\u6309Enter\u952e\u3002<\/p>\n<p>5\u3001\u66f4\u65b0root\u7528\u6237\u7684\u5bc6\u7801\uff0c\u8f93\u5165update user set authentication_string=PASSWORD(&#8216;\u65b0\u5bc6\u7801&#8217;) where User=&#8217;root&#8217;;\uff0c\u5c06&#8217;\u65b0\u5bc6\u7801&#8217;\u66ff\u6362\u4e3a\u4f60\u60f3\u8981\u8bbe\u7f6e\u7684\u65b0\u5bc6\u7801\uff0c\u7136\u540e\u6309Enter\u952e\u3002<\/p>\n<p>6\u3001\u5237\u65b0\u6743\u9650\u5e76\u9000\u51fa\uff0c\u8f93\u5165flush privileges;\uff0c\u7136\u540e\u6309Enter\u952e\u3002\u63a5\u7740\u8f93\u5165quit;\uff0c\u6309Enter\u952e\u9000\u51faMySQL\u63d0\u793a\u7b26\u3002<\/p>\n<p>7\u3001\u6700\u540e\u91cd\u65b0\u542f\u52a8MySQL\u670d\u52a1\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165sudo service mysql start\u6765\u542f\u52a8MySQL\u670d\u52a1\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u91cd\u7f6eMySQL\u6570\u636e\u5e93\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b\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>\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b\uff1f\u8fd9\u662f\u4e0d\u5c11\u7f51\u53cb\u90fd\u5173\u6ce8\u7684\u95ee\u9898\uff0c\u63a5\u4e0b\u6765\u7531php\u5c0f\u7f16\u4e3a\u5927\u5bb6\u5e26\u6765mysql\u5fd8\u8bb0\u5bc6\u7801\u67e5\u770b\u65b9\u6cd5\uff0c\u611f\u5174\u8da3\u7684\u7f51\u53cb\u4e00\u8d77\u968f\u5c0f\u7f16\u6765\u77a7\u77a7\u5427\uff01 mysql\u5fd8\u8bb0\u5bc6\u7801\u67e5\u770b\u65b9\u6cd5 1\u3001\u9996\u5148\uff0c\u505c\u6b62MySQL\u670d\u52a1\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165sudo service mysql stop\u6765\u505c\u6b62MySQL\u670d\u52a1\u3002 2\u3001\u63a5\u7740\uff0c\u4f7f\u7528\u4e00\u4e2a\u7279\u6b8a\u7684\u542f\u52a8\u53c2\u6570\u542f\u52a8MySQL\u670d\u52a1\uff0c\u8be5\u53c2\u6570\u5c06\u8df3\u8fc7\u6743\u9650\u68c0\u67e5\uff0c\u5141\u8bb8\u4f60\u767b\u5f55\u800c\u4e0d\u9700\u8981\u5bc6\u7801\u3002 3\u3001\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165sudo mysqld_safe &#8211;skip-grant-tables &amp;\u6765\u542f\u52a8MySQL\u670d\u52a1\u3002\u7136\u540e\uff0c\u4f7f\u7528root\u7528\u6237\u767b\u5f55\u5230MySQL\u6570\u636e\u5e93\u3002 4\u3001\u5728\u547d\u4ee4\u884c\u8f93\u5165mysql -u root\uff0c\u7136\u540e\u6309Enter\u952e\u3002\u5728MySQL\u63d0\u793a\u7b26\u4e0b\uff0c\u5207\u6362\u5230mysql\u6570\u636e\u5e93\u3002\u8f93\u5165use mysql;\uff0c\u7136\u540e\u6309Enter\u952e\u3002 5\u3001\u66f4\u65b0root\u7528\u6237\u7684\u5bc6\u7801\uff0c\u8f93\u5165update user set authentication_string=PASSWORD(&#8216;\u65b0\u5bc6\u7801&#8217;) where User=&#8217;root&#8217;;\uff0c\u5c06&#8217;\u65b0\u5bc6\u7801&#8217;\u66ff\u6362\u4e3a\u4f60\u60f3\u8981\u8bbe\u7f6e\u7684\u65b0\u5bc6\u7801\uff0c\u7136\u540e\u6309Enter\u952e\u3002 6\u3001\u5237\u65b0\u6743\u9650\u5e76\u9000\u51fa\uff0c\u8f93\u5165flush privileges;\uff0c\u7136\u540e\u6309Enter\u952e\u3002\u63a5\u7740\u8f93\u5165quit;\uff0c\u6309Enter\u952e\u9000\u51faMySQL\u63d0\u793a\u7b26\u3002 7\u3001\u6700\u540e\u91cd\u65b0\u542f\u52a8MySQL\u670d\u52a1\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165sudo service mysql start\u6765\u542f\u52a8MySQL\u670d\u52a1\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u91cd\u7f6eMySQL\u6570\u636e\u5e93\u7684\u5bc6\u7801\u3002 \u4ee5\u4e0a\u5c31\u662f\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u67e5\u770b\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6262","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6262","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=6262"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6262\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}