{"id":6427,"date":"2024-11-14T13:44:01","date_gmt":"2024-11-14T05:44:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6427\/"},"modified":"2024-11-14T13:44:01","modified_gmt":"2024-11-14T05:44:01","slug":"mysql%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b31045%e9%94%99%e8%af%af","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6427\/","title":{"rendered":"mysql\u600e\u4e48\u89e3\u51b31045\u9519\u8bef"},"content":{"rendered":"<blockquote><p>\n  mysql 1045 \u9519\u8bef\u901a\u5e38\u8868\u793a\u8bbf\u95ee\u88ab\u62d2\u7edd\uff0c\u539f\u56e0\u662f\u63d0\u4f9b\u4e86\u9519\u8bef\u7684\u5bc6\u7801\u6216\u7528\u6237\u540d\u3002\u89e3\u51b3\u6b65\u9aa4\u4e3a\uff1a\u9a8c\u8bc1\u51ed\u636e\u68c0\u67e5\u6743\u9650\u91cd\u7f6e\u5bc6\u7801\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u91cd\u65b0\u542f\u52a8 mysql\u68c0\u67e5 my.cnf \u914d\u7f6e\u6587\u4ef6\u7981\u7528 skip-grant-tables\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/02\/2024080207490917217.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u89e3\u51b31045\u9519\u8bef\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u89e3\u51b31045\u9519\u8bef\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL 1045 \u9519\u8bef\uff1a\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>MySQL 1045 \u9519\u8bef\u901a\u5e38\u8868\u793a\u8bbf\u95ee\u88ab\u62d2\u7edd\uff0c\u56e0\u4e3a\u63d0\u4f9b\u4e86\u9519\u8bef\u7684\u5bc6\u7801\u6216\u7528\u6237\u540d\u3002\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<p><strong>1. \u9a8c\u8bc1\u51ed\u636e<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u8f93\u5165\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u6b63\u786e\u7684\u3002<\/li>\n<li>\u68c0\u67e5\u7528\u6237\u540d\u662f\u5426\u5305\u542b\u5927\u5199\u5b57\u6bcd\uff0c\u56e0\u4e3a MySQL \u533a\u5206\u5927\u5c0f\u5199\u3002<\/li>\n<li>\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u51ed\u636e\u91cd\u65b0\u767b\u5f55\uff0c\u4ee5\u786e\u8ba4\u51ed\u636e\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p><strong>2. \u68c0\u67e5\u6743\u9650<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u7528\u6237\u5bf9\u8981\u8bbf\u95ee\u7684\u6570\u636e\u5e93\u548c\u8868\u5177\u6709\u9002\u5f53\u7684\u6743\u9650\u3002<\/li>\n<li>\u4f7f\u7528 GRANT \u8bed\u53e5\u6388\u4e88\u7528\u6237\u5fc5\u8981\u7684\u6743\u9650\u3002<\/li>\n<li>\u5237\u65b0\u6743\u9650\uff0c\u4ee5\u786e\u4fdd\u66f4\u6539\u751f\u6548\uff1aFLUSH PRIVILEGES;<\/li>\n<\/ul>\n<p><strong>3. \u91cd\u7f6e\u5bc6\u7801<\/strong><\/p>\n<ul>\n<li>\n<p>\u5982\u679c\u6000\u7591\u5bc6\u7801\u9519\u8bef\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1a<\/p>\n<pre>ALTER USER 'username'@'hostname' IDENTIFIED BY 'new_password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>4. \u68c0\u67e5\u7f51\u7edc\u8fde\u63a5<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5ba2\u6237\u7aef\u673a\u5668\u548c MySQL \u670d\u52a1\u5668\u4e4b\u95f4\u6709\u7a33\u5b9a\u7684\u7f51\u7edc\u8fde\u63a5\u3002<\/li>\n<li>\u68c0\u67e5\u9632\u706b\u5899\u6216\u5176\u4ed6\u5b89\u5168\u8bbe\u7f6e\u662f\u5426\u963b\u6b62\u4e86\u8fde\u63a5\u3002<\/li>\n<\/ul>\n<p><strong>5. \u91cd\u65b0\u542f\u52a8 MySQL<\/strong><\/p>\n<ul>\n<li>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u5668\u53ef\u4ee5\u89e3\u51b3 1045 \u9519\u8bef\u3002<\/li>\n<\/ul>\n<p><strong>6. \u68c0\u67e5 my.cnf \u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd my.cnf \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u51ed\u636e\u548c\u6743\u9650\u8bbe\u7f6e\u6b63\u786e\u3002<\/li>\n<li>\u67e5\u627e\u5e76\u66f4\u6b63\u4efb\u4f55\u9519\u8bef\u6216\u65e0\u6548\u7684\u8bbe\u7f6e\u3002<\/li>\n<\/ul>\n<p><strong>7. \u7981\u7528 SKIP-GRANT-TABLES<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u542f\u7528\u4e86 SKIP-GRANT-TABLES \u9009\u9879\uff0c\u4f1a\u7ed5\u8fc7\u6743\u9650\u68c0\u67e5\u3002<\/li>\n<li>\n<p>\u7981\u7528\u8be5\u9009\u9879\uff0c\u4ee5\u786e\u4fdd\u6743\u9650\u6b63\u786e\u5b9e\u65bd\uff1a<\/p>\n<pre>SET GLOBAL SKIP-GRANT-TABLES = OFF;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p>\u5982\u679c\u4e0a\u8ff0\u6b65\u9aa4\u65e0\u6cd5\u89e3\u51b3 1045 \u9519\u8bef\uff0c\u8bf7\u8003\u8651\u4ee5\u4e0b\u5176\u4ed6\u56e0\u7d20\uff1a<\/p>\n<ul>\n<li>\u786e\u4fdd MySQL \u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u5e76\u4e14\u53ef\u4ee5\u8bbf\u95ee\u3002<\/li>\n<li>\u68c0\u67e5 MySQL \u65e5\u5fd7\u4ee5\u67e5\u627e\u4efb\u4f55\u989d\u5916\u7684\u9519\u8bef\u6d88\u606f\u3002<\/li>\n<li>\u8054\u7cfb MySQL \u652f\u6301\uff0c\u4ee5\u83b7\u5f97\u66f4\u591a\u5e2e\u52a9\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u89e3\u51b31045\u9519\u8bef\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>mysql 1045 \u9519\u8bef\u901a\u5e38\u8868\u793a\u8bbf\u95ee\u88ab\u62d2\u7edd\uff0c\u539f\u56e0\u662f\u63d0\u4f9b\u4e86\u9519\u8bef\u7684\u5bc6\u7801\u6216\u7528\u6237\u540d\u3002\u89e3\u51b3\u6b65\u9aa4\u4e3a\uff1a\u9a8c\u8bc1\u51ed\u636e\u68c0\u67e5\u6743\u9650\u91cd\u7f6e\u5bc6\u7801\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u91cd\u65b0\u542f\u52a8 mysql\u68c0\u67e5 my.cnf \u914d\u7f6e\u6587\u4ef6\u7981\u7528 skip-grant-tables MySQL 1045 \u9519\u8bef\uff1a\u89e3\u51b3\u65b9\u6848 MySQL 1045 \u9519\u8bef\u901a\u5e38\u8868\u793a\u8bbf\u95ee\u88ab\u62d2\u7edd\uff0c\u56e0\u4e3a\u63d0\u4f9b\u4e86\u9519\u8bef\u7684\u5bc6\u7801\u6216\u7528\u6237\u540d\u3002\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a 1. \u9a8c\u8bc1\u51ed\u636e \u786e\u4fdd\u8f93\u5165\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u6b63\u786e\u7684\u3002 \u68c0\u67e5\u7528\u6237\u540d\u662f\u5426\u5305\u542b\u5927\u5199\u5b57\u6bcd\uff0c\u56e0\u4e3a MySQL \u533a\u5206\u5927\u5c0f\u5199\u3002 \u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u51ed\u636e\u91cd\u65b0\u767b\u5f55\uff0c\u4ee5\u786e\u8ba4\u51ed\u636e\u95ee\u9898\u3002 2. \u68c0\u67e5\u6743\u9650 \u786e\u4fdd\u7528\u6237\u5bf9\u8981\u8bbf\u95ee\u7684\u6570\u636e\u5e93\u548c\u8868\u5177\u6709\u9002\u5f53\u7684\u6743\u9650\u3002 \u4f7f\u7528 GRANT \u8bed\u53e5\u6388\u4e88\u7528\u6237\u5fc5\u8981\u7684\u6743\u9650\u3002 \u5237\u65b0\u6743\u9650\uff0c\u4ee5\u786e\u4fdd\u66f4\u6539\u751f\u6548\uff1aFLUSH PRIVILEGES; 3. \u91cd\u7f6e\u5bc6\u7801 \u5982\u679c\u6000\u7591\u5bc6\u7801\u9519\u8bef\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1a ALTER USER &#8216;username&#8217;@&#8217;hostname&#8217; IDENTIFIED BY &#8216;new_password&#8217;; \u767b\u5f55\u540e\u590d\u5236 4. \u68c0\u67e5\u7f51\u7edc\u8fde\u63a5 \u786e\u4fdd\u5ba2\u6237\u7aef\u673a\u5668\u548c MySQL \u670d\u52a1\u5668\u4e4b\u95f4\u6709\u7a33\u5b9a\u7684\u7f51\u7edc\u8fde\u63a5\u3002 \u68c0\u67e5\u9632\u706b\u5899\u6216\u5176\u4ed6\u5b89\u5168\u8bbe\u7f6e\u662f\u5426\u963b\u6b62\u4e86\u8fde\u63a5\u3002 5. \u91cd\u65b0\u542f\u52a8 MySQL \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u5668\u53ef\u4ee5\u89e3\u51b3 1045 \u9519\u8bef\u3002 6. \u68c0\u67e5 my.cnf [&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-6427","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6427","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=6427"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6427\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}