{"id":5449,"date":"2024-11-14T09:17:13","date_gmt":"2024-11-14T01:17:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5449\/"},"modified":"2024-11-14T09:17:13","modified_gmt":"2024-11-14T01:17:13","slug":"mysql%e5%90%af%e5%8a%a8%e5%a4%b1%e8%b4%a5%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5449\/","title":{"rendered":"mysql\u542f\u52a8\u5931\u8d25\u600e\u4e48\u89e3\u51b3"},"content":{"rendered":"<blockquote><p>\n  mysql \u542f\u52a8\u5931\u8d25\u7684\u539f\u56e0\u5305\u62ec\u7aef\u53e3\u51b2\u7a81\u3001\u6743\u9650\u4e0d\u8db3\u3001\u914d\u7f6e\u6587\u4ef6\u9519\u8bef\u548c\u635f\u574f\u7684\u6587\u4ef6\u3002\u89e3\u51b3\u65b9\u6848\u5305\u62ec\uff1a1. \u68c0\u67e5\u9519\u8bef\u65e5\u5fd7\uff1b2. \u68c0\u67e5\u7aef\u53e3\u51b2\u7a81\uff1b3. \u68c0\u67e5\u6743\u9650\u95ee\u9898\uff1b4. \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u9519\u8bef\uff1b5. \u4fee\u590d\u635f\u574f\u7684\u6587\u4ef6\uff1b6. \u91cd\u7f6e mysql \u5bc6\u7801\uff1b7. \u91cd\u65b0\u5b89\u88c5 mysql\uff1b8. \u5bfb\u6c42\u4e13\u4e1a\u5e2e\u52a9\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/28\/2024052814003741016.jpg\" class=\"aligncenter\" title=\"mysql\u542f\u52a8\u5931\u8d25\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" alt=\"mysql\u542f\u52a8\u5931\u8d25\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u542f\u52a8\u5931\u8d25\u7684\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>MySQL \u542f\u52a8\u5931\u8d25\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u5404\u79cd\u539f\u56e0\u9020\u6210\u7684\u3002\u4ee5\u4e0b\u662f\u89e3\u51b3\u8be5\u95ee\u9898\u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u68c0\u67e5\u9519\u8bef\u65e5\u5fd7<\/strong><\/p>\n<p>\u67e5\u770b MySQL \u9519\u8bef\u65e5\u5fd7\u4ee5\u4e86\u89e3\u9519\u8bef\u7684\u5177\u4f53\u539f\u56e0\u3002\u9519\u8bef\u65e5\u5fd7\u901a\u5e38\u4f4d\u4e8e\u4ee5\u4e0b\u4f4d\u7f6e\uff1a<\/p>\n<ul>\n<li>Linux\uff1a\/var\/log\/\/error.log<\/li>\n<li>Windows\uff1aC:ProgramDataMySQLMySQL Server 8.0Datamysql.err<\/li>\n<\/ul>\n<p><strong>2. \u68c0\u67e5\u7aef\u53e3\u51b2\u7a81<\/strong><\/p>\n<p>MySQL \u9ed8\u8ba4\u4f7f\u7528 3306 \u7aef\u53e3\u3002\u786e\u4fdd\u6ca1\u6709\u4efb\u4f55\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u6b63\u5728\u4f7f\u7528\u6b64\u7aef\u53e3\u3002\u53ef\u4ee5\u4f7f\u7528 netstat -ano \u547d\u4ee4\u67e5\u770b\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u3002<\/p>\n<p><strong>3. \u68c0\u67e5\u6743\u9650\u95ee\u9898<\/strong><\/p>\n<p>MySQL \u8fdb\u7a0b\u9700\u8981 root \u6216\u5177\u6709\u76f8\u5e94\u6743\u9650\u7684\u7528\u6237\u7684\u6743\u9650\u624d\u80fd\u542f\u52a8\u3002\u786e\u4fdd MySQL \u7528\u6237\u62e5\u6709\u5fc5\u8981\u7684\u6743\u9650\u3002<\/p>\n<p><strong>4. \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<p>\u9519\u8bef\u7684 MySQL \u914d\u7f6e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5bfc\u81f4\u542f\u52a8\u5931\u8d25\u3002\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e \/etc\/my.cnf\uff09\u4e2d\u7684\u4ee5\u4e0b\u8bbe\u7f6e\uff1a<\/p>\n<ul>\n<li>mysqld \u7aef\u53e3\u53f7<\/li>\n<li>\u6570\u636e\u76ee\u5f55\u4f4d\u7f6e<\/li>\n<li>\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e<\/li>\n<li>\u7528\u6237\u6743\u9650<\/li>\n<\/ul>\n<p><strong>5. \u4fee\u590d\u635f\u574f\u7684\u6587\u4ef6<\/strong><\/p>\n<p>\u5982\u679c MySQL \u6570\u636e\u6587\u4ef6\u635f\u574f\uff0c\u4e5f\u4f1a\u5bfc\u81f4\u542f\u52a8\u5931\u8d25\u3002\u53ef\u4ee5\u4f7f\u7528 myisamchk -r \u547d\u4ee4\u4fee\u590d MyISAM \u8868\uff0c\u6216\u4f7f\u7528 innodb_file_per_table \u914d\u7f6e\u9009\u9879\u4fee\u590d InnoDB \u8868\u3002<\/p>\n<p><strong>6. \u91cd\u7f6e MySQL \u5bc6\u7801<\/strong><\/p>\n<p>\u5982\u679c\u5fd8\u8bb0\u4e86 MySQL \u5bc6\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u7f6e\uff1a<\/p>\n<pre>mysqld_safe --skip-grant-tables &amp;\nmysql -u root<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u5bc6\u7801\uff1a<\/p>\n<pre>SET PASSWORD = 'new_password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>7. \u91cd\u65b0\u5b89\u88c5 MySQL<\/strong><\/p>\n<p>\u5982\u679c\u4e0a\u8ff0\u6b65\u9aa4\u5747\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u5219\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5 MySQL\u3002\u5378\u200b\u200b\u8f7d\u5e76\u91cd\u65b0\u5b89\u88c5 MySQL \u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u3002<\/p>\n<p><strong>8. \u5bfb\u6c42\u4e13\u4e1a\u5e2e\u52a9<\/strong><\/p>\n<p>\u5982\u679c\u4ecd\u7136\u65e0\u6cd5\u542f\u52a8 MySQL\uff0c\u5219\u53ef\u4ee5\u5bfb\u6c42 MySQL \u8bba\u575b\u6216\u652f\u6301\u4e2d\u5fc3\u7b49\u4e13\u4e1a\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u542f\u52a8\u5931\u8d25\u600e\u4e48\u89e3\u51b3\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 \u542f\u52a8\u5931\u8d25\u7684\u539f\u56e0\u5305\u62ec\u7aef\u53e3\u51b2\u7a81\u3001\u6743\u9650\u4e0d\u8db3\u3001\u914d\u7f6e\u6587\u4ef6\u9519\u8bef\u548c\u635f\u574f\u7684\u6587\u4ef6\u3002\u89e3\u51b3\u65b9\u6848\u5305\u62ec\uff1a1. \u68c0\u67e5\u9519\u8bef\u65e5\u5fd7\uff1b2. \u68c0\u67e5\u7aef\u53e3\u51b2\u7a81\uff1b3. \u68c0\u67e5\u6743\u9650\u95ee\u9898\uff1b4. \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u9519\u8bef\uff1b5. \u4fee\u590d\u635f\u574f\u7684\u6587\u4ef6\uff1b6. \u91cd\u7f6e mysql \u5bc6\u7801\uff1b7. \u91cd\u65b0\u5b89\u88c5 mysql\uff1b8. \u5bfb\u6c42\u4e13\u4e1a\u5e2e\u52a9\u3002 MySQL \u542f\u52a8\u5931\u8d25\u7684\u89e3\u51b3\u65b9\u6cd5 MySQL \u542f\u52a8\u5931\u8d25\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u5404\u79cd\u539f\u56e0\u9020\u6210\u7684\u3002\u4ee5\u4e0b\u662f\u89e3\u51b3\u8be5\u95ee\u9898\u7684\u6b65\u9aa4\uff1a 1. \u68c0\u67e5\u9519\u8bef\u65e5\u5fd7 \u67e5\u770b MySQL \u9519\u8bef\u65e5\u5fd7\u4ee5\u4e86\u89e3\u9519\u8bef\u7684\u5177\u4f53\u539f\u56e0\u3002\u9519\u8bef\u65e5\u5fd7\u901a\u5e38\u4f4d\u4e8e\u4ee5\u4e0b\u4f4d\u7f6e\uff1a Linux\uff1a\/var\/log\/\/error.log Windows\uff1aC:ProgramDataMySQLMySQL Server 8.0Datamysql.err 2. \u68c0\u67e5\u7aef\u53e3\u51b2\u7a81 MySQL \u9ed8\u8ba4\u4f7f\u7528 3306 \u7aef\u53e3\u3002\u786e\u4fdd\u6ca1\u6709\u4efb\u4f55\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u6b63\u5728\u4f7f\u7528\u6b64\u7aef\u53e3\u3002\u53ef\u4ee5\u4f7f\u7528 netstat -ano \u547d\u4ee4\u67e5\u770b\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u3002 3. \u68c0\u67e5\u6743\u9650\u95ee\u9898 MySQL \u8fdb\u7a0b\u9700\u8981 root \u6216\u5177\u6709\u76f8\u5e94\u6743\u9650\u7684\u7528\u6237\u7684\u6743\u9650\u624d\u80fd\u542f\u52a8\u3002\u786e\u4fdd MySQL \u7528\u6237\u62e5\u6709\u5fc5\u8981\u7684\u6743\u9650\u3002 4. \u68c0\u67e5\u914d\u7f6e\u6587\u4ef6 \u9519\u8bef\u7684 MySQL \u914d\u7f6e\u6587\u4ef6\u53ef\u80fd\u4f1a\u5bfc\u81f4\u542f\u52a8\u5931\u8d25\u3002\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u4e8e \/etc\/my.cnf\uff09\u4e2d\u7684\u4ee5\u4e0b\u8bbe\u7f6e\uff1a mysqld \u7aef\u53e3\u53f7 \u6570\u636e\u76ee\u5f55\u4f4d\u7f6e \u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e \u7528\u6237\u6743\u9650 5. [&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-5449","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5449","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=5449"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5449\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}