{"id":6241,"date":"2024-11-14T11:56:39","date_gmt":"2024-11-14T03:56:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6241\/"},"modified":"2024-11-14T11:56:39","modified_gmt":"2024-11-14T03:56:39","slug":"mysql%e5%bf%98%e8%ae%b0%e5%af%86%e7%a0%81%e5%a6%82%e4%bd%95%e8%bf%9b%e5%8e%bb","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6241\/","title":{"rendered":"mysql\u5fd8\u8bb0\u5bc6\u7801\u5982\u4f55\u8fdb\u53bb"},"content":{"rendered":"<blockquote><p>\n  \u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8fdb\u5165\u6570\u636e\u5e93\uff0c\u5373\u4f7f\u5fd8\u8bb0\u4e86 mysql \u5bc6\u7801\uff1a\u91cd\u7f6e\u5bc6\u7801\uff1a \u5982\u679c\u5141\u8bb8\u533f\u540d\u767b\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528 mysql -u root -p \u91cd\u7f6e\u5bc6\u7801\u3002\u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801\uff1a \u5728\u67d0\u4e9b linux \u53d1\u884c\u7248\u4e2d\uff0cmysql \u53ef\u80fd\u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801\uff0c\u53ef\u5728 \/etc\/mysql\/debian.cnf \u4e2d\u627e\u5230\u3002\u91cd\u7f6e\u5bc6\u7801\u6587\u4ef6\uff1a \u505c\u6b62 mysql \u670d\u52a1\uff0c\u91cd\u547d\u540d\u65e5\u5fd7\u6587\u4ef6\uff0c\u5220\u9664 master.info \u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528 set password \u91cd\u7f6e\u5bc6\u7801\u3002\u4f7f\u7528 &#8211;skip-grant-tables \u9009\u9879\uff1a \u7ed5\u8fc7\u6388\u6743\u8868\uff0c\u4f7f\u7528 set pa\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/15\/2024061516004627537.jpg\" class=\"aligncenter\" title=\"mysql\u5fd8\u8bb0\u5bc6\u7801\u5982\u4f55\u8fdb\u53bb\u63d2\u56fe\" alt=\"mysql\u5fd8\u8bb0\u5bc6\u7801\u5982\u4f55\u8fdb\u53bb\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728\u5fd8\u8bb0 MySQL \u5bc6\u7801\u540e\u8fdb\u5165\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u5fd8\u8bb0 MySQL \u5bc6\u7801\u53ef\u80fd\u662f\u4ee4\u4eba\u6cae\u4e27\u7684\uff0c\u4f46\u5e76\u975e\u4e16\u754c\u672b\u65e5\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u8fdb\u5165\u6570\u636e\u5e93\uff1a<\/p>\n<p><strong>1. \u91cd\u7f6e\u5bc6\u7801<\/strong><\/p>\n<p>\u5982\u679c\u670d\u52a1\u5668\u914d\u7f6e\u4e3a\u5141\u8bb8\u4f7f\u7528\u533f\u540d\u767b\u5f55\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1a<\/p>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7cfb\u7edf\u5c06\u63d0\u793a\u4f60\u8f93\u5165\u5bc6\u7801\u3002\u5982\u679c\u5141\u8bb8\u533f\u540d\u767b\u5f55\uff0c\u5b83\u5c06\u8ba9\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u5bc6\u7801\u3002<\/p>\n<p><strong>2. \u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801<\/strong><\/p>\n<p>\u5728\u67d0\u4e9b Linux \u53d1\u884c\u7248\u4e2d\uff0cMySQL \u53ef\u80fd\u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801\u3002\u8be5\u5bc6\u7801\u5b58\u50a8\u5728\/etc\/\/debian.cnf\u6587\u4ef6\u4e2d\u3002\u8981\u627e\u5230\u5bc6\u7801\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>grep 'password' \/etc\/mysql\/debian.cnf<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u91cd\u7f6e\u5bc6\u7801\u6587\u4ef6<\/strong><\/p>\n<p>\u8981\u91cd\u7f6e\u5bc6\u7801\u6587\u4ef6\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u505c\u6b62 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u6570\u636e\u76ee\u5f55\uff08\u901a\u5e38\u4e3a\/var\/lib\/mysql\uff09\u3002<\/li>\n<li>\u91cd\u547d\u540dib_logfile0\u548cib_logfile1\u6587\u4ef6\u3002<\/li>\n<li>\u5220\u9664master.info\u6587\u4ef6\u3002<\/li>\n<li>\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u8fde\u63a5\u5230\u6570\u636e\u5e93\u5e76\u4f7f\u7528SET PASSWORD\u8bed\u53e5\u91cd\u7f6e\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p><strong>4. \u542f\u52a8 MySQL \u65f6\u4f7f\u7528&#8211;skip-grant-tables\u9009\u9879<\/strong><\/p>\n<p>\u8be5\u9009\u9879\u7ed5\u8fc7\u6388\u6743\u8868\uff0c\u5141\u8bb8\u4f60\u4ee5\u4efb\u4f55\u7528\u6237\u8eab\u4efd\u767b\u5f55\u3002\u8981\u4f7f\u7528\u6b64\u9009\u9879\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u505c\u6b62 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u4f7f\u7528&#8211;skip-grant-tables\u9009\u9879\u542f\u52a8 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u8fde\u63a5\u5230\u6570\u636e\u5e93\u5e76\u4f7f\u7528SET PASSWORD\u8bed\u53e5\u91cd\u7f6e\u5bc6\u7801\u3002<\/li>\n<li>\u91cd\u65b0\u542f\u52a8 MySQL \u670d\u52a1\uff0c\u8fd9\u6b21\u4e0d\u4f7f\u7528&#8211;skip-grant-tables\u9009\u9879\u3002<\/li>\n<\/ul>\n<p><strong>5. \u8054\u7cfb MySQL \u652f\u6301<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u65e0\u6cd5\u4f7f\u7528\u4e0a\u8ff0\u4efb\u4f55\u65b9\u6cd5\u91cd\u7f6e\u5bc6\u7801\uff0c\u8bf7\u8054\u7cfb MySQL \u652f\u6301\u3002\u4ed6\u4eec\u53ef\u4ee5\u5e2e\u52a9\u4f60\u91cd\u7f6e\u5bc6\u7801\u6216\u63d0\u4f9b\u5176\u4ed6\u6062\u590d\u9009\u9879\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fd8\u8bb0\u5bc6\u7801\u5982\u4f55\u8fdb\u53bb\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>\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8fdb\u5165\u6570\u636e\u5e93\uff0c\u5373\u4f7f\u5fd8\u8bb0\u4e86 mysql \u5bc6\u7801\uff1a\u91cd\u7f6e\u5bc6\u7801\uff1a \u5982\u679c\u5141\u8bb8\u533f\u540d\u767b\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528 mysql -u root -p \u91cd\u7f6e\u5bc6\u7801\u3002\u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801\uff1a \u5728\u67d0\u4e9b linux \u53d1\u884c\u7248\u4e2d\uff0cmysql \u53ef\u80fd\u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801\uff0c\u53ef\u5728 \/etc\/mysql\/debian.cnf \u4e2d\u627e\u5230\u3002\u91cd\u7f6e\u5bc6\u7801\u6587\u4ef6\uff1a \u505c\u6b62 mysql \u670d\u52a1\uff0c\u91cd\u547d\u540d\u65e5\u5fd7\u6587\u4ef6\uff0c\u5220\u9664 master.info \u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528 set password \u91cd\u7f6e\u5bc6\u7801\u3002\u4f7f\u7528 &#8211;skip-grant-tables \u9009\u9879\uff1a \u7ed5\u8fc7\u6388\u6743\u8868\uff0c\u4f7f\u7528 set pa \u5982\u4f55\u5728\u5fd8\u8bb0 MySQL \u5bc6\u7801\u540e\u8fdb\u5165\u6570\u636e\u5e93 \u5fd8\u8bb0 MySQL \u5bc6\u7801\u53ef\u80fd\u662f\u4ee4\u4eba\u6cae\u4e27\u7684\uff0c\u4f46\u5e76\u975e\u4e16\u754c\u672b\u65e5\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u8fdb\u5165\u6570\u636e\u5e93\uff1a 1. \u91cd\u7f6e\u5bc6\u7801 \u5982\u679c\u670d\u52a1\u5668\u914d\u7f6e\u4e3a\u5141\u8bb8\u4f7f\u7528\u533f\u540d\u767b\u5f55\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\u5bc6\u7801\uff1a mysql -u root -p \u767b\u5f55\u540e\u590d\u5236 \u7cfb\u7edf\u5c06\u63d0\u793a\u4f60\u8f93\u5165\u5bc6\u7801\u3002\u5982\u679c\u5141\u8bb8\u533f\u540d\u767b\u5f55\uff0c\u5b83\u5c06\u8ba9\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u5bc6\u7801\u3002 2. \u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801 \u5728\u67d0\u4e9b Linux \u53d1\u884c\u7248\u4e2d\uff0cMySQL \u53ef\u80fd\u4f7f\u7528\u521d\u59cb\u6839\u5bc6\u7801\u3002\u8be5\u5bc6\u7801\u5b58\u50a8\u5728\/etc\/\/debian.cnf\u6587\u4ef6\u4e2d\u3002\u8981\u627e\u5230\u5bc6\u7801\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a grep &#8216;password&#8217; \/etc\/mysql\/debian.cnf \u767b\u5f55\u540e\u590d\u5236 3. \u91cd\u7f6e\u5bc6\u7801\u6587\u4ef6 [&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-6241","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6241","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=6241"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6241\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}