{"id":5472,"date":"2024-11-14T09:00:00","date_gmt":"2024-11-14T01:00:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5472\/"},"modified":"2024-11-14T09:00:00","modified_gmt":"2024-11-14T01:00:00","slug":"mysql%e5%bf%98%e8%ae%b0%e5%af%86%e7%a0%81%e6%80%8e%e4%b9%88%e6%89%be%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5472\/","title":{"rendered":"mysql\u5fd8\u8bb0\u5bc6\u7801\u600e\u4e48\u627e\u56de"},"content":{"rendered":"<blockquote><p>\n  \u5982\u679c\u60a8\u5fd8\u8bb0\u4e86 mysql \u5bc6\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u627e\u56de\uff1a\u8fde\u63a5\u5230 mysql \u670d\u52a1\u5668\u5e76\u505c\u6b62 mysql \u670d\u52a1\u3002\u4f7f\u7528 &#8211;skip-grant-tables \u9009\u9879\u91cd\u65b0\u542f\u52a8 mysql \u670d\u52a1\u3002\u901a\u8fc7 mysql \u5ba2\u6237\u7a0b\u5e8f\u8fde\u63a5\u5e76\u66f4\u65b0\u5bc6\u7801\u3002\u5237\u65b0\u6743\u9650\u8868\u3002\u505c\u6b62 mysql \u670d\u52a1\u5e76\u6b63\u5e38\u91cd\u65b0\u542f\u52a8\u5b83\u3002\u4f7f\u7528\u65b0\u5bc6\u7801\u767b\u5f55 mysql\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052902482620578.jpg\" class=\"aligncenter\" title=\"mysql\u5fd8\u8bb0\u5bc6\u7801\u600e\u4e48\u627e\u56de\u63d2\u56fe\" alt=\"mysql\u5fd8\u8bb0\u5bc6\u7801\u600e\u4e48\u627e\u56de\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u627e\u56de MySQL \u5bc6\u7801<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u5fd8\u8bb0\u4e86 MySQL \u5bc6\u7801\uff0c\u4ee5\u4e0b\u6b65\u9aa4\u53ef\u4ee5\u5e2e\u52a9\u60a8\u627e\u56de\uff1a<\/p>\n<p><strong>1. \u8bbf\u95ee\u6570\u636e\u5e93\u670d\u52a1\u5668<\/strong><\/p>\n<ul>\n<li>\u901a\u8fc7\u8fdc\u7a0b\u684c\u9762\u6216 SSH \u7b49\u65b9\u5f0f\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u3002<\/li>\n<\/ul>\n<p><strong>2. \u505c\u6b62 MySQL \u670d\u52a1<\/strong><\/p>\n<ul>\n<li>\n<p>\u505c\u6b62 MySQL \u670d\u52a1\u4ee5\u9632\u6b62\u5728\u627e\u56de\u5bc6\u7801\u65f6\u610f\u5916\u66f4\u6539\u6570\u636e\u3002\u5728 Linux \u6216 macOS \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo \/etc\/init.d\/mysql stop<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u5728 Windows \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>net stop mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>3. \u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u4f7f\u7528 &#8211;skip-grant-tables \u9009\u9879<\/strong><\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528 &#8211;skip-grant-tables \u9009\u9879\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u5b83\u5c06\u5141\u8bb8\u60a8\u7ed5\u8fc7\u5bc6\u7801\u9a8c\u8bc1\u3002\u5728 Linux \u6216 macOS \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo \/etc\/init.d\/mysql start --skip-grant-tables<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u5728 Windows \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>net start mysql --skip-grant-tables<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>4. \u8fde\u63a5\u5230 MySQL \u5e76\u66f4\u65b0\u5bc6\u7801<\/strong><\/p>\n<ul>\n<li>\n<p>\u901a\u8fc7 MySQL \u5ba2\u6237\u7a0b\u5e8f\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u5728 Linux\u3001macOS \u6216 Windows \u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>mysql -u root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\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<\/ul>\n<p><strong>5. \u5237\u65b0\u6743\u9650\u8868<\/strong><\/p>\n<ul>\n<li>\n<p>\u73b0\u5728\u9700\u8981\u5237\u65b0\u6743\u9650\u8868\u4ee5\u5e94\u7528\u66f4\u6539\uff1a<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>6. \u505c\u6b62 MySQL \u670d\u52a1<\/strong><\/p>\n<ul>\n<li>\u5237\u65b0\u6743\u9650\u8868\u540e\uff0c\u60a8\u9700\u8981\u505c\u6b62 MySQL \u670d\u52a1\u4ee5\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ul>\n<p><strong>7. \u6b63\u5e38\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1<\/strong><\/p>\n<ul>\n<li>\n<p>\u53bb\u6389 &#8211;skip-grant-tables \u9009\u9879\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u4ee5\u4fbf\u6b63\u5e38\u8fd0\u884c\u3002\u5728 Linux \u6216 macOS \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>sudo \/etc\/init.d\/mysql stop\nsudo \/etc\/init.d\/mysql start<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p>\u5728 Windows \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>net stop mysql\nnet start mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>8. \u4f7f\u7528\u65b0\u5bc6\u7801\u767b\u5f55 MySQL<\/strong><\/p>\n<ul>\n<li>\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u65b0\u5bc6\u7801\u901a\u8fc7 MySQL \u5ba2\u6237\u7a0b\u5e8f\u767b\u5f55\u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fd8\u8bb0\u5bc6\u7801\u600e\u4e48\u627e\u56de\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\u679c\u60a8\u5fd8\u8bb0\u4e86 mysql \u5bc6\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u627e\u56de\uff1a\u8fde\u63a5\u5230 mysql \u670d\u52a1\u5668\u5e76\u505c\u6b62 mysql \u670d\u52a1\u3002\u4f7f\u7528 &#8211;skip-grant-tables \u9009\u9879\u91cd\u65b0\u542f\u52a8 mysql \u670d\u52a1\u3002\u901a\u8fc7 mysql \u5ba2\u6237\u7a0b\u5e8f\u8fde\u63a5\u5e76\u66f4\u65b0\u5bc6\u7801\u3002\u5237\u65b0\u6743\u9650\u8868\u3002\u505c\u6b62 mysql \u670d\u52a1\u5e76\u6b63\u5e38\u91cd\u65b0\u542f\u52a8\u5b83\u3002\u4f7f\u7528\u65b0\u5bc6\u7801\u767b\u5f55 mysql\u3002 \u5982\u4f55\u627e\u56de MySQL \u5bc6\u7801 \u5982\u679c\u60a8\u5fd8\u8bb0\u4e86 MySQL \u5bc6\u7801\uff0c\u4ee5\u4e0b\u6b65\u9aa4\u53ef\u4ee5\u5e2e\u52a9\u60a8\u627e\u56de\uff1a 1. \u8bbf\u95ee\u6570\u636e\u5e93\u670d\u52a1\u5668 \u901a\u8fc7\u8fdc\u7a0b\u684c\u9762\u6216 SSH \u7b49\u65b9\u5f0f\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u3002 2. \u505c\u6b62 MySQL \u670d\u52a1 \u505c\u6b62 MySQL \u670d\u52a1\u4ee5\u9632\u6b62\u5728\u627e\u56de\u5bc6\u7801\u65f6\u610f\u5916\u66f4\u6539\u6570\u636e\u3002\u5728 Linux \u6216 macOS \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo \/etc\/init.d\/mysql stop \u767b\u5f55\u540e\u590d\u5236 \u5728 Windows \u7cfb\u7edf\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a net stop mysql \u767b\u5f55\u540e\u590d\u5236 3. \u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u4f7f\u7528 [&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-5472","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5472","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=5472"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5472\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}