{"id":200013,"date":"2025-05-06T12:06:45","date_gmt":"2025-05-06T04:06:45","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200013\/"},"modified":"2025-05-06T12:06:45","modified_gmt":"2025-05-06T04:06:45","slug":"%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%aemysql-root%e8%b4%a6%e6%88%b7%e7%9a%84%e5%af%86%e7%a0%81%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200013\/","title":{"rendered":"\u5982\u4f55\u8bbe\u7f6eMySQL root\u8d26\u6237\u7684\u5bc6\u7801\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u8bbe\u7f6eMySQL root\u8d26\u6237\u7684\u5bc6\u7801\uff1f<\/h1>\n<p>\u201c\u7eb5\u6709\u75be\u98ce\u6765\uff0c\u4eba\u751f\u4e0d\u8a00\u5f03\u201d\uff0c\u8fd9\u53e5\u8bdd\u9001\u7ed9\u6b63\u5728\u5b66\u4e60\u7684\u670b\u53cb\u4eec\uff0c\u4e5f\u5e0c\u671b\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u591f\u771f\u7684\u5e2e\u52a9\u5230\u5927\u5bb6\u3002\u6211\u4e5f\u4f1a\u5728\u540e\u7eed\u7684\u6587\u7ae0\u4e2d\uff0c\u9646\u7eed\u66f4\u65b0\u76f8\u5173\u7684\u6280\u672f\u6587\u7ae0\uff0c\u6709\u597d\u7684\u5efa\u8bae\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u975e\u5e38\u611f\u8c22\uff01<\/p>\n<p>MySQL \u662f\u4e00\u79cd\u6d41\u884c\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u4e92\u8054\u7f51\u5e94\u7528\u548c\u4f01\u4e1a\u7cfb\u7edf\u4e2d\u3002\u5728 MySQL \u4e2d\uff0croot \u8d26\u6237\u662f\u5177\u6709\u6700\u9ad8\u6743\u9650\u7684\u8d26\u6237\uff0c\u62e5\u6709\u5bf9\u6570\u636e\u5e93\u7684\u5b8c\u5168\u63a7\u5236\u6743\u9650\u3002\u6b63\u786e\u8bbe\u7f6e root \u8d26\u6237\u7684\u5bc6\u7801\u662f\u786e\u4fdd\u6570\u636e\u5e93\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\u4e4b\u4e00\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u8bbe\u7f6e MySQL root \u8d26\u6237\u7684\u5bc6\u7801\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<p>\u5728 MySQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\u8bbe\u7f6e root \u8d26\u6237\u7684\u5bc6\u7801\uff1a<\/p>\n<p>\u6b65\u9aa4\u4e00\uff1a\u767b\u5f55 MySQL<\/p>\n<p>\u9996\u5148\u9700\u8981\u4ee5 root \u7528\u6237\u8eab\u4efd\u767b\u5f55 MySQL \u6570\u636e\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u6216\u8005\u56fe\u5f62\u754c\u9762\u5de5\u5177\u5b9e\u73b0\u767b\u5f55\u3002\u5982\u679c\u662f\u5728\u547d\u4ee4\u884c\u4e0b\u767b\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysql -u root -p<\/pre>\n<p>\u6b64\u547d\u4ee4\u5c06\u63d0\u793a\u8f93\u5165 root \u8d26\u6237\u7684\u5bc6\u7801\uff0c\u8f93\u5165\u6b63\u786e\u5bc6\u7801\u540e\u5373\u53ef\u767b\u5f55 MySQL\u3002<\/p>\n<p>\u6b65\u9aa4\u4e8c\uff1a\u4fee\u6539 root \u8d26\u6237\u5bc6\u7801<\/p>\n<p>\u767b\u5f55\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\u4fee\u6539 root \u8d26\u6237\u7684\u5bc6\u7801\uff1a<\/p>\n<pre>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';<\/pre>\n<p>\u5728\u4e0a\u8ff0 SQL \u8bed\u53e5\u4e2d\uff0c&#8217;new_password&#8217; \u662f\u4f60\u5e0c\u671b\u8bbe\u7f6e\u7684\u65b0\u5bc6\u7801\uff0c\u53ef\u4ee5\u81ea\u884c\u66ff\u6362\u4e3a\u4efb\u610f\u590d\u6742\u7684\u5bc6\u7801\u5b57\u7b26\u4e32\u3002\u6267\u884c\u4ee5\u4e0a SQL \u8bed\u53e5\u540e\uff0croot \u8d26\u6237\u7684\u5bc6\u7801\u5373\u88ab\u6210\u529f\u4fee\u6539\u3002<\/p>\n<p>\u6b65\u9aa4\u4e09\uff1a\u5237\u65b0\u6743\u9650<\/p>\n<p>\u5728\u4fee\u6539 root \u8d26\u6237\u5bc6\u7801\u540e\uff0c\u4e3a\u4e86\u4f7f\u6743\u9650\u53d8\u66f4\u751f\u6548\uff0c\u9700\u8981\u5237\u65b0 MySQL \u7684\u6743\u9650\u7cfb\u7edf\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\u5b9e\u73b0\u6743\u9650\u5237\u65b0\uff1a<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p>\u6267\u884c\u4ee5\u4e0a SQL \u8bed\u53e5\u540e\uff0c\u4e0a\u8ff0\u4fee\u6539\u5c06\u751f\u6548\u5e76\u5e94\u7528\u5230 MySQL \u7684\u6743\u9650\u7cfb\u7edf\u4e2d\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u6210\u529f\u5730\u4fee\u6539\u4e86 MySQL root \u8d26\u6237\u7684\u5bc6\u7801\u5e76\u5237\u65b0\u4e86\u6743\u9650\u7cfb\u7edf\uff0c\u786e\u4fdd\u4e86\u6570\u636e\u5e93\u7684\u5b89\u5168\u6027\u3002\u5728\u8bbe\u7f6e root \u8d26\u6237\u5bc6\u7801\u65f6\uff0c\u5efa\u8bae\u9009\u62e9\u590d\u6742\u4e14\u5b89\u5168\u7684\u5bc6\u7801\uff0c\u4ee5\u9632\u6b62\u672a\u6388\u6743\u8bbf\u95ee\u548c\u6570\u636e\u6cc4\u9732\u3002\u5e0c\u671b\u672c\u6587\u63d0\u4f9b\u7684\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u80fd\u591f\u5e2e\u52a9\u4f60\u6b63\u786e\u8bbe\u7f6e MySQL root \u8d26\u6237\u5bc6\u7801\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u5982\u4f55\u8bbe\u7f6eMySQL root\u8d26\u6237\u7684\u5bc6\u7801\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8eroot\u8d26\u6237\u5bc6\u7801\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u8bbe\u7f6eMySQL root\u8d26\u6237&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200013","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200013"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200013\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}