{"id":6559,"date":"2024-11-14T12:09:12","date_gmt":"2024-11-14T04:09:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6559\/"},"modified":"2024-11-14T12:09:12","modified_gmt":"2024-11-14T04:09:12","slug":"%e6%80%8e%e4%b9%88%e5%af%bc%e5%87%bamysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6559\/","title":{"rendered":"\u600e\u4e48\u5bfc\u51famysql\u6570\u636e\u5e93\u65e5\u5fd7"},"content":{"rendered":"<blockquote><p>\n  \u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5bfc\u51fa mysql \u6570\u636e\u5e93\u65e5\u5fd7\uff1a\u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e\u3002\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u65e5\u5fd7\u6587\u4ef6\uff08mysqldump &#8211;log-error=mysqld.err &#8211;all-databases &gt; database_backup.sql\uff09\u3002\u590d\u5236\u65e5\u5fd7\u6587\u4ef6\uff08cp mysqld.log \/path\/to\/destination\uff09\u3002\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u5bfc\u51fa\u65e5\u5fd7\uff08tail -f \/path\/to\/exported_log_file\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080520244151717.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u5bfc\u51famysql\u6570\u636e\u5e93\u65e5\u5fd7\u63d2\u56fe\" alt=\"\u600e\u4e48\u5bfc\u51famysql\u6570\u636e\u5e93\u65e5\u5fd7\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u65e5\u5fd7<\/strong><\/p>\n<p>\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u65e5\u5fd7\u6709\u52a9\u4e8e\u5728\u9047\u5230\u95ee\u9898\u65f6\u8fdb\u884c\u6545\u969c\u6392\u9664\u548c\u5176\u4ed6\u5206\u6790\u3002\u4ee5\u4e0b\u6b65\u9aa4\u4ecb\u7ecd\u4e86\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u65e5\u5fd7\u7684\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e<\/strong><\/p>\n<ul>\n<li>\u5728 Windows \u4e0a\uff1a%ProgramData%MySQLMySQL Server X.Ylogs<\/li>\n<li>\u5728 macOS \u4e0a\uff1a\/usr\/local\/\/logs<\/li>\n<li>\u5728 Linux \u4e0a\uff1a\/var\/log\/mysql<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 2\uff1a\u5bfc\u51fa\u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u51fa mysqld.log \u6587\u4ef6\uff1a<\/li>\n<\/ul>\n<pre>mysqldump --log-error=mysqld.err --all-databases &gt; database_backup.sql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>mysqldump \u662f\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u7684\u547d\u4ee4\u3002<\/li>\n<li>&#8211;log-error=mysqld.err \u6307\u5b9a\u5bfc\u51fa mysqld.err \u9519\u8bef\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<li>&#8211;all-databases \u5bfc\u51fa\u6240\u6709\u6570\u636e\u5e93\u3002<\/li>\n<li>&gt; database_backup.sql \u6307\u5b9a\u8981\u5c06\u5bfc\u51fa\u7684\u65e5\u5fd7\u4fdd\u5b58\u5230\u7684\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 3\uff1a\u590d\u5236\u65e5\u5fd7\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u4e5f\u53ef\u4ee5\u901a\u8fc7\u590d\u5236 mysqld.log \u6587\u4ef6\u5230\u5176\u4ed6\u4f4d\u7f6e\u6765\u5bfc\u51fa\u65e5\u5fd7\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u590d\u5236\u6587\u4ef6\uff1a<\/li>\n<\/ul>\n<pre>cp mysqld.log \/path\/to\/destination<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 4\uff1a\u67e5\u770b\u5bfc\u51fa\u65e5\u5fd7<\/strong><\/p>\n<ul>\n<li>\u4e00\u65e6\u5bfc\u51fa\u65e5\u5fd7\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u5185\u5bb9\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u65e5\u5fd7\uff1a<\/li>\n<\/ul>\n<pre>tail -f \/path\/to\/exported_log_file<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u5bfc\u51fa\u65e5\u5fd7\u4e4b\u524d\uff0c\u5efa\u8bae\u5907\u4efd MySQL \u6570\u636e\u5e93\u3002<\/li>\n<li>\u5982\u679c mysqld.log \u6587\u4ef6\u592a\u5927\uff0c\u53ef\u4ee5\u5c06\u5176\u538b\u7f29\u4ee5\u8282\u7701\u7a7a\u95f4\u3002<\/li>\n<li>\u5bfc\u51fa\u7684\u65e5\u5fd7\u6587\u4ef6\u5305\u542b\u654f\u611f\u4fe1\u606f\uff0c\u5e94\u59a5\u5584\u4fdd\u7ba1\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5bfc\u51fa\u6570\u636e\u5e93\u65e5\u5fd7\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>\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5bfc\u51fa mysql \u6570\u636e\u5e93\u65e5\u5fd7\uff1a\u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e\u3002\u4f7f\u7528 mysqldump \u547d\u4ee4\u5bfc\u51fa\u65e5\u5fd7\u6587\u4ef6\uff08mysqldump &#8211;log-error=mysqld.err &#8211;all-databases &gt; database_backup.sql\uff09\u3002\u590d\u5236\u65e5\u5fd7\u6587\u4ef6\uff08cp mysqld.log \/path\/to\/destination\uff09\u3002\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6216\u547d\u4ee4\u884c\u5de5\u5177\u67e5\u770b\u5bfc\u51fa\u65e5\u5fd7\uff08tail -f \/path\/to\/exported_log_file\uff09\u3002 \u5982\u4f55\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u65e5\u5fd7 \u5bfc\u51fa MySQL \u6570\u636e\u5e93\u65e5\u5fd7\u6709\u52a9\u4e8e\u5728\u9047\u5230\u95ee\u9898\u65f6\u8fdb\u884c\u6545\u969c\u6392\u9664\u548c\u5176\u4ed6\u5206\u6790\u3002\u4ee5\u4e0b\u6b65\u9aa4\u4ecb\u7ecd\u4e86\u5bfc\u51fa MySQL \u6570\u636e\u5e93\u65e5\u5fd7\u7684\u65b9\u6cd5\uff1a \u6b65\u9aa4 1\uff1a\u786e\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e \u5728 Windows \u4e0a\uff1a%ProgramData%MySQLMySQL Server X.Ylogs \u5728 macOS \u4e0a\uff1a\/usr\/local\/\/logs \u5728 Linux \u4e0a\uff1a\/var\/log\/mysql \u6b65\u9aa4 2\uff1a\u5bfc\u51fa\u65e5\u5fd7\u6587\u4ef6 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u51fa mysqld.log \u6587\u4ef6\uff1a mysqldump &#8211;log-error=mysqld.err &#8211;all-databases &gt; database_backup.sql \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a mysqldump \u662f\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u7684\u547d\u4ee4\u3002 &#8211;log-error=mysqld.err \u6307\u5b9a\u5bfc\u51fa mysqld.err \u9519\u8bef\u65e5\u5fd7\u6587\u4ef6\u3002 &#8211;all-databases \u5bfc\u51fa\u6240\u6709\u6570\u636e\u5e93\u3002 &gt; [&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-6559","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6559","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=6559"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6559\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}