{"id":6188,"date":"2024-11-14T12:52:43","date_gmt":"2024-11-14T04:52:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6188\/"},"modified":"2024-11-14T12:52:43","modified_gmt":"2024-11-14T04:52:43","slug":"mysql%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8broot%e5%af%86%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6188\/","title":{"rendered":"mysql\u5982\u4f55\u67e5\u770broot\u5bc6\u7801"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u67e5\u770b mysql root \u5bc6\u7801\uff1f\u67e5\u770b mysql root \u5bc6\u7801\u7684\u65b9\u6cd5\uff1a\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u4f7f\u7528\u547d\u4ee4\u884c\u8fde\u63a5\u5230 mysql \u670d\u52a1\u5668\u5e76\u6267\u884c\u67e5\u8be2\u91cd\u7f6e\u5bc6\u7801\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/14\/2024061405332393865.jpg\" class=\"aligncenter\" title=\"mysql\u5982\u4f55\u67e5\u770broot\u5bc6\u7801\u63d2\u56fe\" alt=\"mysql\u5982\u4f55\u67e5\u770broot\u5bc6\u7801\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b MySQL root \u5bc6\u7801<\/strong><\/p>\n<p><strong>\u67e5\u770b MySQL root \u5bc6\u7801\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u8981\u67e5\u770b MySQL root \u5bc6\u7801\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u6253\u5f00 MySQL \u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e \/etc\/\/my.cnf \u6216 \/etc\/my.cnf\uff09\u3002<\/li>\n<li>\u67e5\u627e\u4ee5 &#8220;password =&#8221; \u5f00\u5934\u7684\u884c\u3002<\/li>\n<li>\u884c\u503c\u5c06\u662f root \u5bc6\u7801\u7684 hash \u503c\u3002<\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528\u547d\u4ee4\u884c<\/strong><\/p>\n<ul>\n<li>\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a<\/li>\n<\/ul>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8f93\u5165\u5bc6\u7801\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>SELECT user,authentication_string FROM mysql.user WHERE user='root';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8f93\u51fa\u4e2d\u5c06\u663e\u793a root \u5bc6\u7801\u7684 hash \u503c\u3002<\/li>\n<\/ul>\n<p><strong>3. \u91cd\u7f6e\u5bc6\u7801<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u65e0\u6cd5\u67e5\u770b\u73b0\u6709\u7684 root \u5bc6\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u91cd\u7f6e\u5b83\uff1a<\/li>\n<\/ul>\n<pre>sudo service mysql stop\nsudo mysqld_safe --skip-grant-tables &amp;\nmysql -u root mysql\nALTER USER 'root'@'localhost' IDENTIFIED BY '&lt;new_password&gt;';\nflush privileges;\nsudo service mysql restart<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>root \u5bc6\u7801\u662f MySQL \u7684\u5173\u952e\u5b89\u5168\u51ed\u8bc1\u3002\u52a1\u5fc5\u59a5\u5584\u4fdd\u7ba1\u5e76\u907f\u514d\u5c06\u5176\u4e0e\u4efb\u4f55\u4eba\u5171\u4eab\u3002<\/li>\n<li>\u5982\u679c\u60a8\u5728\u67e5\u770b\u6216\u91cd\u7f6e root \u5bc6\u7801\u65f6\u9047\u5230\u95ee\u9898\uff0c\u8bf7\u8054\u7cfb\u7cfb\u7edf\u7ba1\u7406\u5458\u6216\u67e5\u770b MySQL \u6587\u6863\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u67e5\u770broot\u5bc6\u7801\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>\u5982\u4f55\u67e5\u770b mysql root \u5bc6\u7801\uff1f\u67e5\u770b mysql root \u5bc6\u7801\u7684\u65b9\u6cd5\uff1a\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u4f7f\u7528\u547d\u4ee4\u884c\u8fde\u63a5\u5230 mysql \u670d\u52a1\u5668\u5e76\u6267\u884c\u67e5\u8be2\u91cd\u7f6e\u5bc6\u7801 \u5982\u4f55\u67e5\u770b MySQL root \u5bc6\u7801 \u67e5\u770b MySQL root \u5bc6\u7801\u7684\u65b9\u6cd5 \u8981\u67e5\u770b MySQL root \u5bc6\u7801\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a 1. \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6 \u6253\u5f00 MySQL \u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e \/etc\/\/my.cnf \u6216 \/etc\/my.cnf\uff09\u3002 \u67e5\u627e\u4ee5 &#8220;password =&#8221; \u5f00\u5934\u7684\u884c\u3002 \u884c\u503c\u5c06\u662f root \u5bc6\u7801\u7684 hash \u503c\u3002 2. \u4f7f\u7528\u547d\u4ee4\u884c \u4ee5 root \u7528\u6237\u8eab\u4efd\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a mysql -u root -p \u767b\u5f55\u540e\u590d\u5236 \u8f93\u5165\u5bc6\u7801\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a SELECT user,authentication_string FROM mysql.user [&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-6188","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6188","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=6188"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6188\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}