{"id":163887,"date":"2024-11-05T03:15:27","date_gmt":"2024-11-04T19:15:27","guid":{"rendered":"https:\/\/server.hk\/cnblog\/163887\/"},"modified":"2024-11-05T03:15:28","modified_gmt":"2024-11-04T19:15:28","slug":"%e8%a7%a3%e6%b1%ba%e8%99%9b%e6%93%ac%e6%a9%9f%e5%95%9f%e5%8b%95mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e5%95%8f%e9%a1%8c-%e8%99%9b%e6%93%ac%e6%a9%9f%e5%95%9f%e5%8b%95%e4%b8%8d%e4%ba%86mysql","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/163887\/","title":{"rendered":"\u89e3\u6c7a\u865b\u64ec\u6a5f\u555f\u52d5MySQL\u6578\u64da\u5eab\u7684\u554f\u984c (\u865b\u64ec\u6a5f\u555f\u52d5\u4e0d\u4e86mysql\u6578\u64da\u5eab\u55ce)"},"content":{"rendered":"<h1 id=\"%e8%a7%a3%e6%b1%ba%e8%99%9b%e6%93%ac%e6%a9%9f%e5%95%9f%e5%8b%95mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e5%95%8f%e9%a1%8c-eVOeJnKlDN\">\u89e3\u6c7a\u865b\u64ec\u6a5f\u555f\u52d5MySQL\u6578\u64da\u5eab\u7684\u554f\u984c<\/h1>\n<p>\u5728\u4f7f\u7528\u865b\u64ec\u6a5f\uff08VPS\uff09\u6642\uff0cMySQL\u6578\u64da\u5eab\u7684\u555f\u52d5\u554f\u984c\u662f\u8a31\u591a\u7528\u6236\u5e38\u898b\u7684\u6311\u6230\u3002\u7121\u8ad6\u662f\u56e0\u70ba\u914d\u7f6e\u932f\u8aa4\u3001\u8cc7\u6e90\u4e0d\u8db3\u9084\u662f\u5176\u4ed6\u6280\u8853\u554f\u984c\uff0c\u9019\u4e9b\u90fd\u53ef\u80fd\u5c0e\u81f4MySQL\u7121\u6cd5\u6b63\u5e38\u555f\u52d5\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u4e00\u4e9b\u5e38\u898b\u7684\u554f\u984c\u53ca\u5176\u89e3\u6c7a\u65b9\u6848\uff0c\u5e6b\u52a9\u7528\u6236\u6709\u6548\u5730\u6392\u67e5\u548c\u89e3\u6c7a\u9019\u4e9b\u554f\u984c\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e7%9a%84mysql%e5%95%9f%e5%8b%95%e5%95%8f%e9%a1%8c-eVOeJnKlDN\">\u5e38\u898b\u7684MySQL\u555f\u52d5\u554f\u984c<\/h2>\n<p>\u5728\u865b\u64ec\u6a5f\u4e0a\u555f\u52d5MySQL\u6578\u64da\u5eab\u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230\u4ee5\u4e0b\u5e7e\u7a2e\u5e38\u898b\u554f\u984c\uff1a<\/p>\n<ul>\n<li><strong>\u914d\u7f6e\u6587\u4ef6\u932f\u8aa4\uff1a<\/strong>MySQL\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u662fmy.cnf\u6216my.ini\uff09\u4e2d\u53ef\u80fd\u5b58\u5728\u932f\u8aa4\u7684\u8a2d\u7f6e\uff0c\u5c0e\u81f4\u670d\u52d9\u7121\u6cd5\u555f\u52d5\u3002<\/li>\n<li><strong>\u7aef\u53e3\u885d\u7a81\uff1a<\/strong>\u5982\u679cMySQL\u7684\u9810\u8a2d\u7aef\u53e3\uff083306\uff09\u88ab\u5176\u4ed6\u61c9\u7528\u7a0b\u5e8f\u4f54\u7528\uff0c\u5247MySQL\u5c07\u7121\u6cd5\u555f\u52d5\u3002<\/li>\n<li><strong>\u8cc7\u6e90\u4e0d\u8db3\uff1a<\/strong>\u865b\u64ec\u6a5f\u7684\u5167\u5b58\u6216CPU\u8cc7\u6e90\u4e0d\u8db3\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4MySQL\u555f\u52d5\u5931\u6557\u3002<\/li>\n<li><strong>\u6578\u64da\u5eab\u640d\u58de\uff1a<\/strong>\u5982\u679c\u6578\u64da\u5eab\u6587\u4ef6\u640d\u58de\uff0cMySQL\u4e5f\u7121\u6cd5\u6b63\u5e38\u555f\u52d5\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%aa%a2%e6%9f%a5mysql%e5%95%9f%e5%8b%95%e6%97%a5%e8%aa%8c-eVOeJnKlDN\">\u6aa2\u67e5MySQL\u555f\u52d5\u65e5\u8a8c<\/h2>\n<p>\u7576MySQL\u7121\u6cd5\u555f\u52d5\u6642\uff0c\u9996\u5148\u61c9\u6aa2\u67e5MySQL\u7684\u555f\u52d5\u65e5\u8a8c\u3002\u9019\u4e9b\u65e5\u8a8c\u901a\u5e38\u4f4d\u65bc\/var\/log\/mysql\/\u6216\/var\/log\/mysqld.log\u3002\u901a\u904e\u67e5\u770b\u65e5\u8a8c\uff0c\u53ef\u4ee5\u7372\u5f97\u6709\u95dc\u932f\u8aa4\u7684\u5177\u9ad4\u4fe1\u606f\uff0c\u5f9e\u800c\u66f4\u5feb\u5730\u5b9a\u4f4d\u554f\u984c\u3002<\/p>\n<pre><code>tail -n 100 \/var\/log\/mysql\/error.log<\/code><\/pre>\n<h2 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-eVOeJnKlDN\">\u89e3\u6c7a\u65b9\u6848<\/h2>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-eVOeJnKlDN\">1. \u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5MySQL\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u78ba\u4fdd\u6240\u6709\u8a2d\u7f6e\u6b63\u78ba\u7121\u8aa4\u3002\u7279\u5225\u662f\u4ee5\u4e0b\u5e7e\u500b\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><code>datadir<\/code>\uff1a\u78ba\u4fdd\u6578\u64da\u76ee\u9304\u7684\u8def\u5f91\u6b63\u78ba\u4e14\u53ef\u8a2a\u554f\u3002<\/li>\n<li><code>port<\/code>\uff1a\u6aa2\u67e5\u7aef\u53e3\u8a2d\u7f6e\uff0c\u78ba\u4fdd\u6c92\u6709\u5176\u4ed6\u670d\u52d9\u4f54\u7528\u8a72\u7aef\u53e3\u3002<\/li>\n<\/ul>\n<h3 id=\"2-%e6%aa%a2%e6%9f%a5%e8%b3%87%e6%ba%90%e4%bd%bf%e7%94%a8%e6%83%85%e6%b3%81-eVOeJnKlDN\">2. \u6aa2\u67e5\u8cc7\u6e90\u4f7f\u7528\u60c5\u6cc1<\/h3>\n<p>\u4f7f\u7528\u547d\u4ee4\u6aa2\u67e5\u865b\u64ec\u6a5f\u7684\u8cc7\u6e90\u4f7f\u7528\u60c5\u6cc1\uff0c\u78ba\u4fdd\u6709\u8db3\u5920\u7684\u5167\u5b58\u548cCPU\u53ef\u7528\uff1a<\/p>\n<pre><code>free -m<\/code><\/pre>\n<pre><code>top<\/code><\/pre>\n<h3 id=\"3-%e4%bf%ae%e5%be%a9%e6%95%b8%e6%93%9a%e5%ba%ab-eVOeJnKlDN\">3. \u4fee\u5fa9\u6578\u64da\u5eab<\/h3>\n<p>\u5982\u679c\u61f7\u7591\u6578\u64da\u5eab\u640d\u58de\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u4fee\u5fa9\uff1a<\/p>\n<pre><code>mysqlcheck -u root -p --auto-repair --all-databases<\/code><\/pre>\n<h3 id=\"4-%e9%87%8d%e6%96%b0%e5%95%9f%e5%8b%95mysql%e6%9c%8d%e5%8b%99-eVOeJnKlDN\">4. \u91cd\u65b0\u555f\u52d5MySQL\u670d\u52d9<\/h3>\n<p>\u5728\u9032\u884c\u4e0a\u8ff0\u6aa2\u67e5\u548c\u4fee\u5fa9\u5f8c\uff0c\u5617\u8a66\u91cd\u65b0\u555f\u52d5MySQL\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart mysql<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-eVOeJnKlDN\">\u7d50\u8ad6<\/h2>\n<p>\u5728\u865b\u64ec\u6a5f\u4e0a\u555f\u52d5MySQL\u6578\u64da\u5eab\u6642\uff0c\u9047\u5230\u554f\u984c\u662f\u5e38\u898b\u7684\u60c5\u6cc1\u3002\u901a\u904e\u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6\u3001\u8cc7\u6e90\u4f7f\u7528\u60c5\u6cc1\u3001\u6578\u64da\u5eab\u72c0\u614b\u4ee5\u53ca\u555f\u52d5\u65e5\u8a8c\uff0c\u901a\u5e38\u53ef\u4ee5\u5feb\u901f\u5b9a\u4f4d\u4e26\u89e3\u6c7a\u554f\u984c\u3002\u5982\u679c\u60a8\u5728\u89e3\u6c7a\u904e\u7a0b\u4e2d\u9047\u5230\u56f0\u96e3\uff0c\u5efa\u8b70\u5c0b\u6c42\u5c08\u696d\u7684\u6280\u8853\u652f\u6301\u3002<\/p>\n<p>\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u7684\u6578\u64da\u5eab\u670d\u52d9\u7684\u7528\u6236\uff0c\u9078\u64c7\u5408\u9069\u7684\u865b\u64ec\u6a5f\u65b9\u6848\u81f3\u95dc\u91cd\u8981\u3002\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u6211\u5011\u7684<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u89e3\u6c7a\u65b9\u6848\uff0c\u8b93\u60a8\u7684\u6578\u64da\u5eab\u904b\u884c\u66f4\u52a0\u9806\u66a2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a\u865b\u64ec\u6a5f\u555f\u52d5MySQL\u6578\u64da\u5eab\u7684\u554f\u984c\uff0c\u63d0\u4f9b\u6709\u6548\u7684\u6545\u969c\u6392\u9664\u65b9\u6cd5\uff0c\u5e6b\u52a9\u60a8\u5feb\u901f\u6062\u5fa9\u6578\u64da\u5eab\u904b\u884c\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-163887","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=163887"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163887\/revisions"}],"predecessor-version":[{"id":163888,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/163887\/revisions\/163888"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=163887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=163887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=163887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}