{"id":5274,"date":"2024-11-14T09:45:30","date_gmt":"2024-11-14T01:45:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5274\/"},"modified":"2024-11-14T09:45:30","modified_gmt":"2024-11-14T01:45:30","slug":"mysql%e4%b8%8d%e7%9f%a5%e9%81%93%e5%af%86%e7%a0%81%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5274\/","title":{"rendered":"mysql\u4e0d\u77e5\u9053\u5bc6\u7801\u600e\u4e48\u529e"},"content":{"rendered":"<blockquote><p>\n  \u5fd8\u8bb0 mysql \u5bc6\u7801\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u91cd\u7f6e\u5bc6\u7801\uff1a\u505c\u6b62 mysql \u670d\u52a1\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 mysql\u8fde\u63a5\u5230 mysql\u91cd\u7f6e root \u7528\u6237\u5bc6\u7801\u5237\u65b0\u6743\u9650\u9000\u51fa mysql\u542f\u52a8 mysql \u670d\u52a1\u4f7f\u7528\u65b0\u5bc6\u7801\u8fde\u63a5\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052618092470165.jpg\" class=\"aligncenter\" title=\"mysql\u4e0d\u77e5\u9053\u5bc6\u7801\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"mysql\u4e0d\u77e5\u9053\u5bc6\u7801\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5fd8\u8bb0 MySQL \u5bc6\u7801<\/strong><\/p>\n<p><strong>\u5982\u4f55\u91cd\u7f6e MySQL \u5bc6\u7801<\/strong><\/p>\n<p>\u5fd8\u8bb0 MySQL \u5bc6\u7801\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8bef\uff0c\u4f46\u4e0d\u8981\u60ca\u614c\u3002\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u91cd\u7f6e\u5bc6\u7801\u5e76\u91cd\u65b0\u8bbf\u95ee\u6570\u636e\u5e93\uff1a<\/p>\n<p><strong>1. \u505c\u6b62 MySQL \u670d\u52a1<\/strong><\/p>\n<p>\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u4f7f\u7528\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>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 MySQL\uff1a<\/p>\n<pre>sudo mysqld_safe --skip-grant-tables<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u542f\u52a8 MySQL \u800c\u65e0\u9700\u9a8c\u8bc1\u5bc6\u7801\u3002<\/p>\n<p><strong>3. \u8fde\u63a5\u5230 MySQL<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230 MySQL\uff1a<\/p>\n<pre>mysql -u root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u60a8\u65e0\u9700\u8f93\u5165\u5bc6\u7801\uff0c\u56e0\u4e3a\u60a8\u5df2\u5728\u5355\u7528\u6237\u6a21\u5f0f\u4e0b\u542f\u52a8\u4e86 MySQL\u3002<\/p>\n<p><strong>4. \u91cd\u7f6e\u5bc6\u7801<\/strong><\/p>\n<p>\u8f93\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<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5237\u65b0\u6743\u9650\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>\u8f93\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. \u542f\u52a8 MySQL \u670d\u52a1<\/strong><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\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<\/strong><\/p>\n<p>\u73b0\u5728\u60a8\u53ef\u4ee5\u4f7f\u7528\u65b0\u5bc6\u7801\u8fde\u63a5\u5230 MySQL\uff1a<\/p>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u5165\u60a8\u8bbe\u7f6e\u7684\u65b0\u5bc6\u7801\u3002<\/p>\n<p><strong>\u5b89\u5168\u63d0\u793a<\/strong><\/p>\n<ul>\n<li>\u52a1\u5fc5\u9009\u62e9\u4e00\u4e2a\u5f3a\u5bc6\u7801\u3002<\/li>\n<li>\u5c06\u5bc6\u7801\u5b58\u50a8\u5728\u5b89\u5168\u7684\u5730\u65b9\u3002<\/li>\n<li>\u5b9a\u671f\u66f4\u6539\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e0d\u77e5\u9053\u5bc6\u7801\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>\u5fd8\u8bb0 mysql \u5bc6\u7801\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u91cd\u7f6e\u5bc6\u7801\uff1a\u505c\u6b62 mysql \u670d\u52a1\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 mysql\u8fde\u63a5\u5230 mysql\u91cd\u7f6e root \u7528\u6237\u5bc6\u7801\u5237\u65b0\u6743\u9650\u9000\u51fa mysql\u542f\u52a8 mysql \u670d\u52a1\u4f7f\u7528\u65b0\u5bc6\u7801\u8fde\u63a5 \u5fd8\u8bb0 MySQL \u5bc6\u7801 \u5982\u4f55\u91cd\u7f6e MySQL \u5bc6\u7801 \u5fd8\u8bb0 MySQL \u5bc6\u7801\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8bef\uff0c\u4f46\u4e0d\u8981\u60ca\u614c\u3002\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u91cd\u7f6e\u5bc6\u7801\u5e76\u91cd\u65b0\u8bbf\u95ee\u6570\u636e\u5e93\uff1a 1. \u505c\u6b62 MySQL \u670d\u52a1 \u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u4f7f\u7528\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 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5355\u7528\u6237\u6a21\u5f0f\u542f\u52a8 MySQL\uff1a sudo mysqld_safe &#8211;skip-grant-tables \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u542f\u52a8 MySQL \u800c\u65e0\u9700\u9a8c\u8bc1\u5bc6\u7801\u3002 3. \u8fde\u63a5\u5230 MySQL \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230 MySQL\uff1a mysql -u root \u767b\u5f55\u540e\u590d\u5236 \u60a8\u65e0\u9700\u8f93\u5165\u5bc6\u7801\uff0c\u56e0\u4e3a\u60a8\u5df2\u5728\u5355\u7528\u6237\u6a21\u5f0f\u4e0b\u542f\u52a8\u4e86 [&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-5274","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5274","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=5274"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5274\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}