{"id":6452,"date":"2024-11-14T09:21:54","date_gmt":"2024-11-14T01:21:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6452\/"},"modified":"2024-11-14T09:21:54","modified_gmt":"2024-11-14T01:21:54","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84%e5%af%86%e7%a0%81%e5%bf%98%e4%ba%86%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6452\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u7684\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u529e"},"content":{"rendered":"<blockquote><p>\n  \u627e\u56de mysql \u5bc6\u7801\u7684\u65b9\u6cd5\uff1a\u4f7f\u7528 root \u5e10\u6237\u767b\u5f55\uff0c\u8f93\u5165 root \u5bc6\u7801\u3002\u5982\u679c\u5fd8\u8bb0 root \u5bc6\u7801\uff0c\u91cd\u542f\u670d\u52a1\u5668\u5e76\u8fdb\u5165\u5b89\u5168\u6a21\u5f0f\uff0c\u4f7f\u7528\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\u3002\u5982\u679c\u6ca1\u6709 root \u5bc6\u7801\uff0c\u4f7f\u7528\u6062\u590d\u6a21\u5f0f\u91cd\u7f6e\u5bc6\u7801\u3002\u8054\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u5458\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080507434947032.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u7684\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u7684\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u5bc6\u7801\u9057\u5fd8\u7684\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u5fd8\u8bb0 MySQL \u6570\u636e\u5e93\u5bc6\u7801\u53ef\u80fd\u4f1a\u662f\u4e00\u4e2a\u4ee4\u4eba\u6cae\u4e27\u7684\u95ee\u9898\uff0c\u4f46\u4e0d\u7528\u62c5\u5fc3\uff0c\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u627e\u56de\u5bc6\u7801\u6216\u5c06\u5176\u91cd\u7f6e\u3002<\/p>\n<p><strong>1. \u4f7f\u7528 root \u5e10\u6237\u767b\u5f55<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u6709 root \u5e10\u6237\u7684\u5bc6\u7801\uff0c\u4f60\u53ef\u4ee5\u7ed5\u8fc7\u4e22\u5931\u7684\u5bc6\u7801\u5e76\u91cd\u7f6e MySQL \u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n<ul>\n<li>\u767b\u5f55\u5230 MySQL shell \u4f5c\u4e3a root \u7528\u6237\uff1a -u root -p<\/li>\n<li>\u8f93\u5165 root \u5bc6\u7801\u5e76\u6309 Enter\u3002<\/li>\n<li>\u5982\u679c\u4f60\u5fd8\u8bb0\u4e86 root \u5bc6\u7801\uff0c\u8bf7\u53c2\u9605\u4e0b\u9762\u7b2c 2 \u8282\u3002<\/li>\n<\/ul>\n<p><strong>2. \u91cd\u7f6e root \u5bc6\u7801<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u5fd8\u8bb0\u4e86 root \u5bc6\u7801\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u91cd\u7f6e\uff1a<\/p>\n<ul>\n<li>\u91cd\u542f\u670d\u52a1\u5668\u5e76\u8fdb\u5165<strong>\u5b89\u5168\u6a21\u5f0f<\/strong>\u3002\u5728\u542f\u52a8\u65f6\uff0c\u6309\u4f4f <strong>Shift<\/strong> \u952e\u3002<\/li>\n<li>\u4e00\u65e6\u4f60\u8fdb\u5165\u5b89\u5168\u6a21\u5f0f\uff0c\u9009\u62e9\u542f\u52a8\u9009\u9879\uff1a<strong>\u542f\u7528\u7f51\u7edc<\/strong>\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1asudo \/usr\/libexec\/mysqld -u root -p &#8211;skip-grant-tables<\/li>\n<li>\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u5bc6\u7801\uff0c\u7136\u540e\u4fdd\u5b58\u66f4\u6539\uff1aALTER USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;new-password&#8217;;<\/li>\n<li>\u9000\u51fa MySQL shell\uff1aexit<\/li>\n<li>\u91cd\u542f\u670d\u52a1\u5668\uff1asudo reboot<\/li>\n<\/ul>\n<p><strong>3. \u4f7f\u7528\u6062\u590d\u6a21\u5f0f<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u6ca1\u6709 root \u5e10\u6237\u7684\u5bc6\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528<strong>\u6062\u590d\u6a21\u5f0f<\/strong>\u6765\u91cd\u7f6e\u5bc6\u7801\u3002<\/p>\n<ul>\n<li>\u91cd\u542f\u670d\u52a1\u5668\u5e76\u8fdb\u5165<strong>\u6062\u590d\u6a21\u5f0f<\/strong>\u3002\u5728\u542f\u52a8\u65f6\uff0c\u6309\u4f4f <strong>Cmd<\/strong> + <strong>R<\/strong> \u952e\u3002<\/li>\n<li>\u9009\u62e9<strong>\u5b9e\u7528\u5de5\u5177<\/strong>\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9<strong>\u7ec8\u7aef<\/strong>\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1aresetpassword<\/li>\n<li>\u6309\u7167\u63d0\u793a\u64cd\u4f5c\u5e76\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p><strong>4. \u8054\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u5458<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u65e0\u6cd5\u91cd\u7f6e\u5bc6\u7801\uff0c\u8bf7\u8054\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u5458\u3002\u4ed6\u4eec\u53ef\u80fd\u62e5\u6709\u91cd\u7f6e\u5bc6\u7801\u6240\u9700\u7684\u6743\u9650\u3002<\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u4e3a\u4e86\u907f\u514d\u5c06\u6765\u4e22\u5931\u5bc6\u7801\uff0c\u8bf7\u5b9a\u671f\u5907\u4efd MySQL \u6570\u636e\u5e93\u3002<\/li>\n<li>\u542f\u7528 MySQL \u7684\u5b89\u5168\u529f\u80fd\uff0c\u5982 SSL \u52a0\u5bc6\u548c\u3002<\/li>\n<li>\u8003\u8651\u4f7f\u7528\u5bc6\u7801\u7ba1\u7406\u5668\u6765\u5b58\u50a8\u548c\u7ba1\u7406\u4f60\u7684\u6570\u636e\u5e93\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u7684\u5bc6\u7801\u5fd8\u4e86\u600e\u4e48\u529e\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>\u627e\u56de mysql \u5bc6\u7801\u7684\u65b9\u6cd5\uff1a\u4f7f\u7528 root \u5e10\u6237\u767b\u5f55\uff0c\u8f93\u5165 root \u5bc6\u7801\u3002\u5982\u679c\u5fd8\u8bb0 root \u5bc6\u7801\uff0c\u91cd\u542f\u670d\u52a1\u5668\u5e76\u8fdb\u5165\u5b89\u5168\u6a21\u5f0f\uff0c\u4f7f\u7528\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\u3002\u5982\u679c\u6ca1\u6709 root \u5bc6\u7801\uff0c\u4f7f\u7528\u6062\u590d\u6a21\u5f0f\u91cd\u7f6e\u5bc6\u7801\u3002\u8054\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u5458\u3002 MySQL \u5bc6\u7801\u9057\u5fd8\u7684\u89e3\u51b3\u65b9\u6848 \u5fd8\u8bb0 MySQL \u6570\u636e\u5e93\u5bc6\u7801\u53ef\u80fd\u4f1a\u662f\u4e00\u4e2a\u4ee4\u4eba\u6cae\u4e27\u7684\u95ee\u9898\uff0c\u4f46\u4e0d\u7528\u62c5\u5fc3\uff0c\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u627e\u56de\u5bc6\u7801\u6216\u5c06\u5176\u91cd\u7f6e\u3002 1. \u4f7f\u7528 root \u5e10\u6237\u767b\u5f55 \u5982\u679c\u4f60\u6709 root \u5e10\u6237\u7684\u5bc6\u7801\uff0c\u4f60\u53ef\u4ee5\u7ed5\u8fc7\u4e22\u5931\u7684\u5bc6\u7801\u5e76\u91cd\u7f6e MySQL \u7528\u6237\u7684\u5bc6\u7801\u3002 \u767b\u5f55\u5230 MySQL shell \u4f5c\u4e3a root \u7528\u6237\uff1a -u root -p \u8f93\u5165 root \u5bc6\u7801\u5e76\u6309 Enter\u3002 \u5982\u679c\u4f60\u5fd8\u8bb0\u4e86 root \u5bc6\u7801\uff0c\u8bf7\u53c2\u9605\u4e0b\u9762\u7b2c 2 \u8282\u3002 2. \u91cd\u7f6e root \u5bc6\u7801 \u5982\u679c\u4f60\u5fd8\u8bb0\u4e86 root \u5bc6\u7801\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u91cd\u7f6e\uff1a \u91cd\u542f\u670d\u52a1\u5668\u5e76\u8fdb\u5165\u5b89\u5168\u6a21\u5f0f\u3002\u5728\u542f\u52a8\u65f6\uff0c\u6309\u4f4f Shift \u952e\u3002 \u4e00\u65e6\u4f60\u8fdb\u5165\u5b89\u5168\u6a21\u5f0f\uff0c\u9009\u62e9\u542f\u52a8\u9009\u9879\uff1a\u542f\u7528\u7f51\u7edc\u3002 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1asudo [&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-6452","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6452","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=6452"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6452\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}