{"id":6001,"date":"2024-11-14T08:30:35","date_gmt":"2024-11-14T00:30:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6001\/"},"modified":"2024-11-14T08:30:35","modified_gmt":"2024-11-14T00:30:35","slug":"%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9mysql%e5%af%86%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6001\/","title":{"rendered":"\u5982\u4f55\u4fee\u6539mysql\u5bc6\u7801"},"content":{"rendered":"<p><strong>\u5982\u4f55\u4fee\u6539  \u5bc6\u7801<\/strong><\/p>\n<p><strong>\u76f4\u63a5\u4fee\u6539<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u767b\u5f55 MySQL \u6570\u636e\u5e93\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u7528 root \u7528\u6237\u540d\u548c\u73b0\u6709\u5bc6\u7801\u767b\u5f55\uff1a<\/p>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li> <strong>\u8f93\u5165\u5f53\u524d\u5bc6\u7801\uff1a<\/strong>\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u5f53\u524d\u5bc6\u7801\u3002<\/li>\n<li>\n<p><strong>\u66f4\u6539\u5bc6\u7801\uff1a<\/strong>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u5bc6\u7801\u66f4\u6539\u4e3a\u60a8\u9009\u62e9\u7684\u65b0\u5bc6\u7801\uff1a<\/p>\n<pre>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5237\u65b0\u6743\u9650\uff1a<\/strong>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5e94\u7528\u66f4\u6539\uff1a<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p><strong>\u4f7f\u7528\u5fd8\u8bb0\u5bc6\u7801\u7684\u547d\u4ee4<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u5fd8\u8bb0\u4e86\u5bc6\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528 mysqld_safe \u547d\u4ee4\u91cd\u7f6e\u5b83\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u505c\u6b62 MySQL \u670d\u52a1\uff1a<\/strong>\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo systemctl stop mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u4f7f\u7528\u5fd8\u8bb0\u5bc6\u7801\u6a21\u5f0f\u542f\u52a8 MySQL\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fd0\u884c MySQL \u4ee5\u5fd8\u8bb0\u5bc6\u7801\u6a21\u5f0f\uff1a<\/p>\n<pre>sudo mysqld_safe --skip-grant-tables &amp;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u767b\u5f55 MySQL\uff1a<\/strong>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u65e0\u9700\u5bc6\u7801\u767b\u5f55 MySQL\uff1a<\/p>\n<pre>mysql -u root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li> <strong>\u66f4\u6539\u5bc6\u7801\uff1a<\/strong>\u5c31\u50cf\u5728\u76f4\u63a5\u4fee\u6539\u65b9\u6cd5\u4e2d\u4e00\u6837\uff0c\u8f93\u5165 ALTER USER \u547d\u4ee4\u66f4\u6539\u5bc6\u7801\u3002<\/li>\n<li> <strong>\u5237\u65b0\u6743\u9650\uff1a<\/strong>\u540c\u6837\uff0c\u4f7f\u7528 FLUSH PRIVILEGES \u547d\u4ee4\u5e94\u7528\u66f4\u6539\u3002<\/li>\n<li>\n<p><strong>\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff1a<\/strong>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff1a<\/p>\n<pre>sudo systemctl start mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4fee\u6539\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\u4fee\u6539 \u5bc6\u7801 \u76f4\u63a5\u4fee\u6539 \u767b\u5f55 MySQL \u6570\u636e\u5e93\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u7528 root \u7528\u6237\u540d\u548c\u73b0\u6709\u5bc6\u7801\u767b\u5f55\uff1a mysql -u root -p \u767b\u5f55\u540e\u590d\u5236 \u8f93\u5165\u5f53\u524d\u5bc6\u7801\uff1a\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u5f53\u524d\u5bc6\u7801\u3002 \u66f4\u6539\u5bc6\u7801\uff1a\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u5bc6\u7801\u66f4\u6539\u4e3a\u60a8\u9009\u62e9\u7684\u65b0\u5bc6\u7801\uff1a ALTER USER &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;new_password&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5237\u65b0\u6743\u9650\uff1a\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5e94\u7528\u66f4\u6539\uff1a FLUSH PRIVILEGES; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5fd8\u8bb0\u5bc6\u7801\u7684\u547d\u4ee4 \u5982\u679c\u60a8\u5fd8\u8bb0\u4e86\u5bc6\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528 mysqld_safe \u547d\u4ee4\u91cd\u7f6e\u5b83\uff1a \u505c\u6b62 MySQL \u670d\u52a1\uff1a\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo systemctl stop mysql \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528\u5fd8\u8bb0\u5bc6\u7801\u6a21\u5f0f\u542f\u52a8 MySQL\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fd0\u884c MySQL \u4ee5\u5fd8\u8bb0\u5bc6\u7801\u6a21\u5f0f\uff1a sudo mysqld_safe &#8211;skip-grant-tables &amp; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55 MySQL\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u65e0\u9700\u5bc6\u7801\u767b\u5f55 MySQL\uff1a mysql -u root [&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-6001","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6001","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=6001"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6001\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}