<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; mysql 碎片</title>
	<atom:link href="https://www.xifenfei.com/tag/mysql-%e7%a2%8e%e7%89%87/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Wed, 04 Nov 2026 15:33:30 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>文件系统格式化MySQL数据库恢复</title>
		<link>https://www.xifenfei.com/2025/06/format-disk-mysql-recovery.html</link>
		<comments>https://www.xifenfei.com/2025/06/format-disk-mysql-recovery.html#comments</comments>
		<pubDate>Wed, 18 Jun 2025 15:38:17 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[mysql 碎片]]></category>
		<category><![CDATA[格式化mysql恢复]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=11507</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2025/06/format-disk-mysql-recovery.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2025/06/format-disk-mysql-recovery.html" target="_blank">文件系统格式化MySQL数据库恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>有客户在做迁移的时候,不慎把存放mysql数据库的硬盘进行了重新分区格式化,重新初始化mysql,并且导入了部分历史数据,不能满足客户需求,希望我们帮忙进行数据恢复.里面大概有100套左右mysql数据库,每个库里面表结构相同,数据不一样.接手这个故障,第一操作就是对磁盘进行镜像,然后使用恢复工具进行底层分析,尝试从文件系统层面恢复出来被格式化之前的数据库文件(需要有对应库目录,不然也没有意义,因为每个库里面表结构一样的,没有正确的库名字无法做到有效的区分),通过底层扫描分析,没有发现一个有效数据文件<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2025/06/QQ20250618-232447.png"><img src="https://www.xifenfei.com/wp-content/uploads/2025/06/QQ20250618-232447.png" alt="QQ20250618-232447" width="1138" height="277" class="alignleft size-full wp-image-11508" /></a><br />
<hr />
对于这样的情况,只能寄希望于mysql 数据块层面扫描恢复,通过工具扫描发现大量的数据块page文件<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2025/06/block-page.png"><img src="https://www.xifenfei.com/wp-content/uploads/2025/06/block-page.png" alt="block-page" width="682" height="541" class="alignleft size-full wp-image-11509" /></a><br />
<hr />
然后尝试分析字典信息,主要是对于0000000000000001.page对应的表创建语句为:</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE `SYS_TABLES` (
  `NAME` varchar(255) NOT NULL DEFAULT '',
  `ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `N_COLS` int(10) DEFAULT NULL,
  `TYPE` int(10) unsigned DEFAULT NULL,
  `MIX_ID` bigint(20) unsigned DEFAULT NULL,
  `MIX_LEN` int(10) unsigned DEFAULT NULL,
  `CLUSTER_NAME` varchar(255) DEFAULT NULL,
  `SPACE` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</pre>
<p>通过上述信息可以获取到name和id列的值(其中name中包含库名/表名),然后再通过0000000000000003.page文件结合对应的表创建语句:</p>
<pre class="brush: sql; title: ; notranslate">
CREATE TABLE `SYS_INDEXES` (
  `TABLE_ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `ID` bigint(20) unsigned NOT NULL DEFAULT '0',
  `NAME` varchar(120) DEFAULT NULL,
  `N_FIELDS` int(10) unsigned DEFAULT NULL,
  `TYPE` int(10) unsigned DEFAULT NULL,
  `SPACE` int(10) unsigned DEFAULT NULL,
  `PAGE_NO` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`TABLE_ID`,`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</pre>
<p>这个主要是或者表id和page id的对应关系(表id直接关联SYS_TABLES.ID,然后获取SYS_TABLES.NAME和SYS_INDEXES.ID对应关系,从而可以确定每一个表对应的需要恢复的page文件信息,再通过客户提供的表语句和对应的page关系,实现相关数据恢复,具体操作可以参考以往类似文章:<br />
<a href="https://www.xifenfei.com/2021/01/xfs-mysql-drop-recovery.html" title="xfs文件系统mysql删库恢复">xfs文件系统mysql删库恢复</a><br />
<a href="https://www.xifenfei.com/2020/05/mysql-rm-database-recovery.html" title="又一起mysql rm删除数据库目录事故" rel="noopener" target="_blank">又一起mysql rm删除数据库目录事故</a><br />
<a href="https://www.xifenfei.com/2015/08/mysql%e6%81%a2%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%ad%97%e5%85%b8%e8%a1%a8%e8%ae%b2%e8%a7%a3.html" title="[MySQL异常恢复]恢复数据字典表讲解" rel="noopener" target="_blank">[MySQL异常恢复]恢复数据字典表讲解</a><br />
<a href="https://www.xifenfei.com/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html" title="[MySQL异常恢复]mysql drop table 数据恢复" rel="noopener" target="_blank">[MySQL异常恢复]mysql drop table 数据恢复</a><br />
<a href="https://www.xifenfei.com/2022/07/mysql-ibd-undelete-error-recovery.html" title="mysql ibd文件反删除恢复之后异常处理">mysql ibd文件反删除恢复之后异常处理</a><br />
<a href="https://www.xifenfei.com/2014/12/%e4%bd%bf%e7%94%a8%e5%b7%a5%e5%85%b7%e7%9b%b4%e6%8e%a5%e6%8a%bd%e5%8f%96mysql%e6%95%b0%e6%8d%ae%e5%ad%97%e5%85%b8.html" title="[MySQL异常恢复]使用工具直接抽取MySQL数据字典" rel="noopener" target="_blank">[MySQL异常恢复]使用工具直接抽取MySQL数据字典</a><br />
<a href="https://www.xifenfei.com/2015/08/mysql-recovery-support.html" title="MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)" rel="noopener" target="_blank">MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)</a></p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/08/mysql%e6%81%a2%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%ad%97%e5%85%b8%e8%a1%a8%e8%ae%b2%e8%a7%a3.html" rel="bookmark" class="crp_title">[MySQL异常恢复]恢复数据字典表讲解</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/09/mysql-init-recovery.html" rel="bookmark" class="crp_title">应用连接错误,初始化mysql数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/01/xfs-mysql-drop-recovery.html" rel="bookmark" class="crp_title">xfs文件系统mysql删库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2020/03/mysql-ransomware-recovery.html" rel="bookmark" class="crp_title">MySQL勒索恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/12/mysql-ibd-recovery.html" rel="bookmark" class="crp_title">[MySQL异常恢复]mysql ibd文件恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2014/12/%e4%bd%bf%e7%94%a8%e5%b7%a5%e5%85%b7%e7%9b%b4%e6%8e%a5%e6%8a%bd%e5%8f%96mysql%e6%95%b0%e6%8d%ae%e5%ad%97%e5%85%b8.html" rel="bookmark" class="crp_title">[MySQL异常恢复]使用工具直接抽取MySQL数据字典</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2020/02/mysql-datadir-rm-recovery.html" rel="bookmark" class="crp_title">mysql 数据库目录被删除恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/09/mysql-recovery-2-case.html" rel="bookmark" class="crp_title">docker回收和mysql备份导入导致数据丢失恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/12/frm-ibm-recovery.html" rel="bookmark" class="crp_title">frm和ibd文件数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/07/mysql-ibd-undelete-error-recovery.html" rel="bookmark" class="crp_title">mysql ibd文件反删除恢复之后异常处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/11/mysql-drop-database-recovery.html" rel="bookmark" class="crp_title">mysql drop database 恢复思路</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/10/a_h_readme_to_recover.html" rel="bookmark" class="crp_title">A_H_README_TO_RECOVER勒索恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2025/06/format-disk-mysql-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
