{"id":6494,"date":"2024-11-14T09:34:33","date_gmt":"2024-11-14T01:34:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6494\/"},"modified":"2024-11-14T09:34:33","modified_gmt":"2024-11-14T01:34:33","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%88%a0%e9%99%a4%e6%80%8e%e4%b9%88%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6494\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u5220\u9664\u600e\u4e48\u6062\u590d"},"content":{"rendered":"<blockquote><p>\n  mysql \u6570\u636e\u5e93\u4e2d\u5220\u9664\u7684\u6570\u636e\u6062\u590d\u65b9\u6cd5\uff1a\u68c0\u67e5\u56de\u6536\u7ad9\uff08mysql 8.0 \u53ca\u4ee5\u4e0a\u7248\u672c\uff09\u4f7f\u7528\u5907\u4efd\u6062\u590d\u4f7f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d\uff08\u9700\u542f\u7528 binlog\uff09\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080517374860082.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u5220\u9664\u600e\u4e48\u6062\u590d\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u5220\u9664\u600e\u4e48\u6062\u590d\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u6570\u636e\u5e93\u5220\u9664\u6062\u590d<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong>MySQL \u6570\u636e\u5e93\u4e2d\u5220\u9664\u7684\u6570\u636e\u5982\u4f55\u6062\u590d\uff1f<\/p>\n<p><strong>\u56de\u7b54\uff1a<\/strong><\/p>\n<p>\u6570\u636e\u6062\u590d\u662f MySQL \u6570\u636e\u5e93\u7ba1\u7406\u4e2d\u81f3\u5173\u91cd\u8981\u7684\u4e00\u6b65\u3002\u5982\u679c\u4e0d\u5c0f\u5fc3\u5220\u9664\u4e86\u6570\u636e\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u6062\u590d\uff1a<\/p>\n<p><span>\u70b9\u51fb\u4e0b\u8f7d<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>1. \u786e\u5b9a\u5df2\u5220\u9664\u7684\u6570\u636e<\/strong><\/p>\n<p>\u786e\u5b9a\u4e22\u5931\u6570\u636e\u7684\u8868\u3001\u8bb0\u5f55\u548c\u5217\uff0c\u4ee5\u53ca\u5220\u9664\u7684\u65f6\u95f4\u8303\u56f4\u3002<\/p>\n<p><strong>2. \u68c0\u67e5\u56de\u6536\u7ad9<\/strong><\/p>\n<p>MySQL 8.0 \u53ca\u66f4\u9ad8\u7248\u672c\u5f15\u5165\u4e86\u56de\u6536\u7ad9\u529f\u80fd\u3002\u5982\u679c\u6570\u636e\u6700\u8fd1\u5220\u9664\uff0c\u53ef\u4ee5\u5728\u56de\u6536\u7ad9\u4e2d\u627e\u5230\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SHOW RECOVERED TABLES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u4f7f\u7528\u5907\u4efd\u6062\u590d<\/strong><\/p>\n<p>\u5982\u679c\u5728\u5220\u9664\u6570\u636e\u4e4b\u524d\u5df2\u521b\u5efa\u4e86\u6570\u636e\u5e93\u5907\u4efd\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u5907\u4efd\u6062\u590d\u6570\u636e\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li>\u505c\u6b62 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u590d\u5236\u5907\u4efd\u6587\u4ef6\u5230 MySQL \u6570\u636e\u76ee\u5f55\u3002<\/li>\n<li>\u542f\u52a8 MySQL \u670d\u52a1\u3002<\/li>\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u6570\u636e\u6062\u590d\u5230\u6570\u636e\u5e93\uff1a<\/li>\n<\/ul>\n<pre>mysql -u root -p\nUSE your_database;\nRESTORE TABLE table_name FROM '\/path\/to\/backup.sql';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u4f7f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d<\/strong><\/p>\n<p>\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u4e2d\u53d1\u751f\u7684\u6240\u6709\u66f4\u6539\u3002\u5982\u679c\u542f\u7528\u4e86\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff0c\u5219\u53ef\u4ee5\u4ece\u4e2d\u6062\u590d\u5df2\u5220\u9664\u7684\u6570\u636e\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ul>\n<li>\u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6\uff08my.cnf\uff09\u4ee5\u542f\u7528 binlog\u3002<\/li>\n<li>\u627e\u5230\u8bb0\u5f55\u5220\u9664\u64cd\u4f5c\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528 binlog \u5de5\u5177\u89e3\u6790\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u751f\u6210\u5305\u542b\u5220\u9664\u64cd\u4f5c\u7684 SQL \u8bed\u53e5\u6587\u4ef6\u3002<\/li>\n<li>\u6267\u884c SQL \u8bed\u53e5\u6587\u4ef6\u4ee5\u6062\u590d\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u53ca\u65f6\u5907\u4efd\u6570\u636e\u5e93\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u5b89\u5168\u3002<\/li>\n<li>\u5b9a\u671f\u68c0\u67e5\u56de\u6536\u7ad9\uff0c\u5c24\u5176\u662f\u6267\u884c\u5927\u89c4\u6a21\u5220\u9664\u64cd\u4f5c\u4e4b\u540e\u3002<\/li>\n<li>\u5728\u4f7f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d\u6570\u636e\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u7406\u89e3\u6240\u6d89\u53ca\u7684\u98ce\u9669\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u5220\u9664\u600e\u4e48\u6062\u590d\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 \u6570\u636e\u5e93\u4e2d\u5220\u9664\u7684\u6570\u636e\u6062\u590d\u65b9\u6cd5\uff1a\u68c0\u67e5\u56de\u6536\u7ad9\uff08mysql 8.0 \u53ca\u4ee5\u4e0a\u7248\u672c\uff09\u4f7f\u7528\u5907\u4efd\u6062\u590d\u4f7f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d\uff08\u9700\u542f\u7528 binlog\uff09 MySQL \u6570\u636e\u5e93\u5220\u9664\u6062\u590d \u95ee\u9898\uff1aMySQL \u6570\u636e\u5e93\u4e2d\u5220\u9664\u7684\u6570\u636e\u5982\u4f55\u6062\u590d\uff1f \u56de\u7b54\uff1a \u6570\u636e\u6062\u590d\u662f MySQL \u6570\u636e\u5e93\u7ba1\u7406\u4e2d\u81f3\u5173\u91cd\u8981\u7684\u4e00\u6b65\u3002\u5982\u679c\u4e0d\u5c0f\u5fc3\u5220\u9664\u4e86\u6570\u636e\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u6062\u590d\uff1a \u70b9\u51fb\u4e0b\u8f7d\u201c\u201d\uff1b 1. \u786e\u5b9a\u5df2\u5220\u9664\u7684\u6570\u636e \u786e\u5b9a\u4e22\u5931\u6570\u636e\u7684\u8868\u3001\u8bb0\u5f55\u548c\u5217\uff0c\u4ee5\u53ca\u5220\u9664\u7684\u65f6\u95f4\u8303\u56f4\u3002 2. \u68c0\u67e5\u56de\u6536\u7ad9 MySQL 8.0 \u53ca\u66f4\u9ad8\u7248\u672c\u5f15\u5165\u4e86\u56de\u6536\u7ad9\u529f\u80fd\u3002\u5982\u679c\u6570\u636e\u6700\u8fd1\u5220\u9664\uff0c\u53ef\u4ee5\u5728\u56de\u6536\u7ad9\u4e2d\u627e\u5230\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a SHOW RECOVERED TABLES; \u767b\u5f55\u540e\u590d\u5236 3. \u4f7f\u7528\u5907\u4efd\u6062\u590d \u5982\u679c\u5728\u5220\u9664\u6570\u636e\u4e4b\u524d\u5df2\u521b\u5efa\u4e86\u6570\u636e\u5e93\u5907\u4efd\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u5907\u4efd\u6062\u590d\u6570\u636e\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u505c\u6b62 MySQL \u670d\u52a1\u3002 \u590d\u5236\u5907\u4efd\u6587\u4ef6\u5230 MySQL \u6570\u636e\u76ee\u5f55\u3002 \u542f\u52a8 MySQL \u670d\u52a1\u3002 \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u6570\u636e\u6062\u590d\u5230\u6570\u636e\u5e93\uff1a mysql -u root -p USE your_database; RESTORE TABLE table_name FROM &#8216;\/path\/to\/backup.sql&#8217;; \u767b\u5f55\u540e\u590d\u5236 4. \u4f7f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u6062\u590d \u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\u4e86\u6570\u636e\u5e93\u4e2d\u53d1\u751f\u7684\u6240\u6709\u66f4\u6539\u3002\u5982\u679c\u542f\u7528\u4e86\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff0c\u5219\u53ef\u4ee5\u4ece\u4e2d\u6062\u590d\u5df2\u5220\u9664\u7684\u6570\u636e\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u4fee\u6539 [&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-6494","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6494","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=6494"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6494\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}