{"id":5417,"date":"2024-11-14T08:59:00","date_gmt":"2024-11-14T00:59:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5417\/"},"modified":"2024-11-14T08:59:00","modified_gmt":"2024-11-14T00:59:00","slug":"%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8bmysql%e6%97%a5%e5%bf%97%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5417\/","title":{"rendered":"\u600e\u4e48\u67e5\u770bmysql\u65e5\u5fd7\u6587\u4ef6"},"content":{"rendered":"<blockquote><p>\n  mysql\u65e5\u5fd7\u6587\u4ef6\u8bb0\u5f55\u4e86\u670d\u52a1\u5668\u64cd\u4f5c\u548c\u4e8b\u4ef6\uff0c\u5bf9\u4e8e\u8bca\u65ad\u95ee\u9898\u81f3\u5173\u91cd\u8981\u3002\u67e5\u770b\u65e5\u5fd7\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e\uff1alinux\/macos\uff1a\/var\/log\/mysql\uff1bwindows\uff1ac:programdatamysqlmysql server [version number]data\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u68c0\u67e5\u65e5\u5fd7\u5185\u5bb9\uff0c\u5305\u62ec\u9519\u8bef\u3001\u8fde\u63a5\u3001\u67e5\u8be2\u3001\u914d\u7f6e\u66f4\u6539\u548c\u6027\u80fd\u6307\u6807\u901a\u8fc7mysql\u547d\u4ee4\u884c\u3001mysql workbench\u6216log viewer\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/28\/2024052811572674027.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u67e5\u770bmysql\u65e5\u5fd7\u6587\u4ef6\u63d2\u56fe\" alt=\"\u600e\u4e48\u67e5\u770bmysql\u65e5\u5fd7\u6587\u4ef6\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b MySQL \u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<p>MySQL \u65e5\u5fd7\u6587\u4ef6\u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u64cd\u4f5c\u548c\u4e8b\u4ef6\u3002\u67e5\u770b\u8fd9\u4e9b\u65e5\u5fd7\u5bf9\u4e8e\u8bca\u65ad\u95ee\u9898\u3001\u8fdb\u884c\u6545\u969c\u6392\u9664\u4ee5\u53ca\u76d1\u63a7\u670d\u52a1\u5668\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>1. \u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u7684\u4f4d\u7f6e<\/strong><\/p>\n<p>MySQL \u65e5\u5fd7\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\u4ee5\u4e0b\u76ee\u5f55\u4e2d\uff1a<\/p>\n<ul>\n<li>Linux\/macOS\uff1a\/var\/log\/ <\/li>\n<li>Windows\uff1aC:ProgramDataMySQLMySQL Server [version number]data<\/li>\n<\/ul>\n<p><strong>2. \u67e5\u770b\u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u3002\u4ee5\u4e0b\u547d\u4ee4\u7528\u4e8e\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n<pre>sudo vi \/var\/log\/mysql\/error.log<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728 Windows \u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u8bb0\u4e8b\u672c\u6216\u5176\u4ed6\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p><strong>3. \u68c0\u67e5\u65e5\u5fd7\u5185\u5bb9<\/strong><\/p>\n<p>\u65e5\u5fd7\u6587\u4ef6\u5305\u542b\u5404\u79cd\u4fe1\u606f\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u9519\u8bef\u548c\u8b66\u544a\u6d88\u606f<\/li>\n<li>\u5ba2\u6237\u673a\u8fde\u63a5\u548c\u65ad\u5f00\u8fde\u63a5\u4e8b\u4ef6<\/li>\n<li>\u67e5\u8be2\u6267\u884c\u7edf\u8ba1\u4fe1\u606f<\/li>\n<li>\u670d\u52a1\u5668\u914d\u7f6e\u66f4\u6539<\/li>\n<li>\u6027\u80fd\u6307\u6807<\/li>\n<\/ul>\n<p><strong>\u5e38\u89c1\u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li> <strong>error.log\uff1a<\/strong>\u8bb0\u5f55\u9519\u8bef\u548c\u8b66\u544a\u6d88\u606f\u3002<\/li>\n<li> <strong>general.log\uff1a<\/strong>\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u548c\u6570\u636e\u5e93\u64cd\u4f5c\u3002<\/li>\n<li> <strong>slow.log\uff1a<\/strong>\u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7279\u5b9a\u9608\u503c\u7684\u67e5\u8be2\u3002<\/li>\n<li> <strong>binary.log\uff1a<\/strong>\u8bb0\u5f55\u6570\u636e\u5e93\u66f4\u6539\u7684\u4e8b\u52a1\u65e5\u5fd7\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u65b9\u6cd5<\/strong><\/p>\n<p>\u9664\u4e86\u76f4\u63a5\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li> <strong>MySQL \u547d\u4ee4\u884c\uff1a<\/strong>\u4f7f\u7528 SHOW BINARY LOGS\u3001SHOW ERRORS \u548c SHOW SLOW LOGS \u547d\u4ee4\u67e5\u770b\u65e5\u5fd7\u5185\u5bb9\u3002<\/li>\n<li> <strong>MySQL Workbench\uff1a<\/strong>\u8fde\u63a5\u5230\u670d\u52a1\u5668\u5e76\u5bfc\u822a\u5230\u201c\u670d\u52a1\u5668\u72b6\u6001\u201d\u9009\u9879\u5361\uff0c\u4ee5\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\u3002<\/li>\n<li> <strong>Log Viewer \u5de5\u5177\uff1a<\/strong>\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\uff08\u4f8b\u5982 MySQL Log Viewer\uff09\u89e3\u6790\u548c\u53ef\u89c6\u5316\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\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\u65e5\u5fd7\u6587\u4ef6\u8bb0\u5f55\u4e86\u670d\u52a1\u5668\u64cd\u4f5c\u548c\u4e8b\u4ef6\uff0c\u5bf9\u4e8e\u8bca\u65ad\u95ee\u9898\u81f3\u5173\u91cd\u8981\u3002\u67e5\u770b\u65e5\u5fd7\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e\uff1alinux\/macos\uff1a\/var\/log\/mysql\uff1bwindows\uff1ac:programdatamysqlmysql server [version number]data\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u68c0\u67e5\u65e5\u5fd7\u5185\u5bb9\uff0c\u5305\u62ec\u9519\u8bef\u3001\u8fde\u63a5\u3001\u67e5\u8be2\u3001\u914d\u7f6e\u66f4\u6539\u548c\u6027\u80fd\u6307\u6807\u901a\u8fc7mysql\u547d\u4ee4\u884c\u3001mysql workbench\u6216log viewer\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f \u5982\u4f55\u67e5\u770b MySQL \u65e5\u5fd7\u6587\u4ef6 MySQL \u65e5\u5fd7\u6587\u4ef6\u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u64cd\u4f5c\u548c\u4e8b\u4ef6\u3002\u67e5\u770b\u8fd9\u4e9b\u65e5\u5fd7\u5bf9\u4e8e\u8bca\u65ad\u95ee\u9898\u3001\u8fdb\u884c\u6545\u969c\u6392\u9664\u4ee5\u53ca\u76d1\u63a7\u670d\u52a1\u5668\u81f3\u5173\u91cd\u8981\u3002 \u6b65\u9aa4\uff1a 1. \u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u7684\u4f4d\u7f6e MySQL \u65e5\u5fd7\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\u4ee5\u4e0b\u76ee\u5f55\u4e2d\uff1a Linux\/macOS\uff1a\/var\/log\/ Windows\uff1aC:ProgramDataMySQLMySQL Server [version number]data 2. \u67e5\u770b\u65e5\u5fd7\u6587\u4ef6 \u60a8\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u3002\u4ee5\u4e0b\u547d\u4ee4\u7528\u4e8e\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff1a sudo vi \/var\/log\/mysql\/error.log \u767b\u5f55\u540e\u590d\u5236 \u5728 Windows \u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u8bb0\u4e8b\u672c\u6216\u5176\u4ed6\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u65e5\u5fd7\u6587\u4ef6\u3002 3. \u68c0\u67e5\u65e5\u5fd7\u5185\u5bb9 \u65e5\u5fd7\u6587\u4ef6\u5305\u542b\u5404\u79cd\u4fe1\u606f\uff0c\u5305\u62ec\uff1a \u9519\u8bef\u548c\u8b66\u544a\u6d88\u606f \u5ba2\u6237\u673a\u8fde\u63a5\u548c\u65ad\u5f00\u8fde\u63a5\u4e8b\u4ef6 \u67e5\u8be2\u6267\u884c\u7edf\u8ba1\u4fe1\u606f \u670d\u52a1\u5668\u914d\u7f6e\u66f4\u6539 \u6027\u80fd\u6307\u6807 \u5e38\u89c1\u65e5\u5fd7\u6587\u4ef6 error.log\uff1a\u8bb0\u5f55\u9519\u8bef\u548c\u8b66\u544a\u6d88\u606f\u3002 general.log\uff1a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u548c\u6570\u636e\u5e93\u64cd\u4f5c\u3002 slow.log\uff1a\u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7279\u5b9a\u9608\u503c\u7684\u67e5\u8be2\u3002 binary.log\uff1a\u8bb0\u5f55\u6570\u636e\u5e93\u66f4\u6539\u7684\u4e8b\u52a1\u65e5\u5fd7\u3002 \u5176\u4ed6\u65b9\u6cd5 \u9664\u4e86\u76f4\u63a5\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\uff1a MySQL \u547d\u4ee4\u884c\uff1a\u4f7f\u7528 SHOW BINARY LOGS\u3001SHOW ERRORS \u548c SHOW SLOW [&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-5417","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5417","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=5417"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5417\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}