{"id":5292,"date":"2024-11-14T10:43:02","date_gmt":"2024-11-14T02:43:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5292\/"},"modified":"2024-11-14T10:43:02","modified_gmt":"2024-11-14T02:43:02","slug":"%e5%bf%98%e8%ae%b0mysql%e5%af%86%e7%a0%81%e6%80%8e%e4%b9%88%e8%a7%a3%e9%94%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5292\/","title":{"rendered":"\u5fd8\u8bb0mysql\u5bc6\u7801\u600e\u4e48\u89e3\u9501"},"content":{"rendered":"<p><strong>\u5982\u4f55\u89e3\u9501\u5fd8\u8bb0\u7684  \u5bc6\u7801<\/strong><\/p>\n<p>\u5982\u679c\u5fd8\u8bb0\u4e86 MySQL \u6570\u636e\u5e93\u7684\u5bc6\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u89e3\u9501\uff1a<\/p>\n<p><strong>1. \u505c\u6b62 MySQL \u670d\u52a1<\/strong><\/p>\n<p>\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u505c\u6b62 MySQL \u670d\u52a1\uff1a<\/p>\n<pre>sudo service mysql stop<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 MySQL<\/strong><\/p>\n<p>\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 MySQL\uff0c\u8fd9\u6837\u53ef\u4ee5\u4e0d\u4f7f\u7528\u5bc6\u7801\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a<\/p>\n<pre>sudo mysqld_safe --skip-grant-tables &amp;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u8fde\u63a5\u5230 MySQL<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fde\u63a5\u5230 MySQL\uff1a<\/p>\n<pre>mysql -u root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7531\u4e8e\u8df3\u8fc7\u4e86\u6388\u6743\u8868\uff0c\u56e0\u6b64\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u5373\u53ef\u8fde\u63a5\u3002<\/p>\n<p><strong>4. \u91cd\u7f6e\u5bc6\u7801<\/strong><\/p>\n<p>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e root \u7528\u6237\u7684\u5bc6\u7801\uff1a<\/p>\n<pre>UPDATE mysql.user SET Password=PASSWORD('\u65b0\u5bc6\u7801') WHERE User='root';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u5237\u65b0\u6743\u9650\u8868<\/strong><\/p>\n<p>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5237\u65b0\u6743\u9650\u8868\uff0c\u4f7f\u5176\u66f4\u65b0\u4e3a\u65b0\u5bc6\u7801\uff1a<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. \u9000\u51fa MySQL<\/strong><\/p>\n<p>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa MySQL\uff1a<\/p>\n<pre>exit<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>7. \u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff1a<\/p>\n<pre>sudo service mysql start<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>8. \u4f7f\u7528\u65b0\u5bc6\u7801\u8fde\u63a5 MySQL<\/strong><\/p>\n<p>\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528\u65b0\u5bc6\u7801\u8fde\u63a5\u5230 MySQL\uff1a<\/p>\n<pre>mysql -u root -p'\u65b0\u5bc6\u7801'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fd8\u8bb0\u5bc6\u7801\u600e\u4e48\u89e3\u9501\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\u89e3\u9501\u5fd8\u8bb0\u7684 \u5bc6\u7801 \u5982\u679c\u5fd8\u8bb0\u4e86 MySQL \u6570\u636e\u5e93\u7684\u5bc6\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u89e3\u9501\uff1a 1. \u505c\u6b62 MySQL \u670d\u52a1 \u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u505c\u6b62 MySQL \u670d\u52a1\uff1a sudo service mysql stop \u767b\u5f55\u540e\u590d\u5236 2. \u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 MySQL \u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 MySQL\uff0c\u8fd9\u6837\u53ef\u4ee5\u4e0d\u4f7f\u7528\u5bc6\u7801\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a sudo mysqld_safe &#8211;skip-grant-tables &amp; \u767b\u5f55\u540e\u590d\u5236 3. \u8fde\u63a5\u5230 MySQL \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fde\u63a5\u5230 MySQL\uff1a mysql -u root \u767b\u5f55\u540e\u590d\u5236 \u7531\u4e8e\u8df3\u8fc7\u4e86\u6388\u6743\u8868\uff0c\u56e0\u6b64\u65e0\u9700\u8f93\u5165\u5bc6\u7801\u5373\u53ef\u8fde\u63a5\u3002 4. \u91cd\u7f6e\u5bc6\u7801 \u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e root \u7528\u6237\u7684\u5bc6\u7801\uff1a UPDATE mysql.user SET Password=PASSWORD(&#8216;\u65b0\u5bc6\u7801&#8217;) WHERE User=&#8217;root&#8217;; \u767b\u5f55\u540e\u590d\u5236 5. \u5237\u65b0\u6743\u9650\u8868 \u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5237\u65b0\u6743\u9650\u8868\uff0c\u4f7f\u5176\u66f4\u65b0\u4e3a\u65b0\u5bc6\u7801\uff1a FLUSH [&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-5292","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5292","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=5292"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5292\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}