<?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%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8d/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>Thu, 29 Oct 2026 15:31:46 +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/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</link>
		<comments>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#comments</comments>
		<pubDate>Sat, 22 Aug 2015 18:00:04 +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=6050</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <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">继续阅读 <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/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" target="_blank">[MySQL异常恢复]恢复数据字典表讲解</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在以前的文章中说过mysql的数据字典的恢复(<a href="//www.xifenfei.com/?p=5669" title="使用工具直接抽取MySQL数据字典" target="_blank">使用工具直接抽取MySQL数据字典</a>,缺少SYS_FIELDS表),主要的数据字典有一下几个，在本文中主要对这些数据字典的意义进行一些讲解，为大家更深一步了解mysql恢复处理思路<br />
<strong>MySQL恢复字典表</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; show tables;
+----------------+
| Tables_in_test |
+----------------+
| SYS_COLUMNS    | 
| SYS_FIELDS     | 
| SYS_INDEXES    | 
| SYS_TABLES     | 
+----------------+
4 rows in set (0.00 sec)
</pre>
<p><strong>SYS_TABLES</strong><br />
这个表是mysql恢复的最核心的表之一，主要是记录数据库在InnoDB中表的信息。它默认写在InnoDB的index_ids为1的里面，它的根页在8号page上，他的主要列结构为：</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; desc SYS_TABLES;
+--------------+---------------------+------+-----+---------+-------+
| Field        | Type                | Null | Key | Default | Extra |
+--------------+---------------------+------+-----+---------+-------+
| NAME         | varchar(255)        | NO   | PRI |         |       | 
| ID           | bigint(20) unsigned | NO   |     | 0       |       | 
| N_COLS       | int(10)             | YES  |     | NULL    |       | 
| TYPE         | int(10) unsigned    | YES  |     | NULL    |       | 
| MIX_ID       | bigint(20) unsigned | YES  |     | NULL    |       | 
| MIX_LEN      | int(10) unsigned    | YES  |     | NULL    |       | 
| CLUSTER_NAME | varchar(255)        | YES  |     | NULL    |       | 
| SPACE        | int(10) unsigned    | YES  |     | NULL    |       | 
+--------------+---------------------+------+-----+---------+-------+
8 rows in set (0.00 sec)
</pre>
<p>NAME:顾名思义,就是表的名字,但是注意他记录的格式是db/table,例如:xifenfei/zx_users,表示为xifenfei数据库中的zx_users表<br />
ID:表的编号<br />
N_COLS:表一共包含的列的数量<br />
TYPE, MIX_ID, MIX_LEN 和 CLUSTER_NAME列,对于数据库恢复无任何意义不做描述<br />
SPACE:表空间的标示列. 例如： ibdata1 是 SPACE 0, ibdata2 是 SPACE 1, 每一个 ibd 文件都有自己的表空间标示.<br />
<br />
<strong>SYS_INDEXES</strong><br />
这个也是mysql恢复的最核心表之一,主要是记录InnoDB的index信息,它默认InnoDB的index_ids为3的里面，他的主要结构为：</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; desc SYS_INDEXES;
+----------+---------------------+------+-----+---------+-------+
| Field    | Type                | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| TABLE_ID | bigint(20) unsigned | NO   | PRI | 0       |       | 
| ID       | bigint(20) unsigned | NO   | PRI | 0       |       | 
| NAME     | varchar(120)        | YES  |     | NULL    |       | 
| N_FIELDS | int(10) unsigned    | YES  |     | NULL    |       | 
| TYPE     | int(10) unsigned    | YES  |     | NULL    |       | 
| SPACE    | int(10) unsigned    | YES  |     | NULL    |       | 
| PAGE_NO  | int(10) unsigned    | YES  |     | NULL    |       | 
+----------+---------------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
</pre>
<p>TABLE_ID:表标示列,为SYS_TABLES.ID<br />
ID:为InnoDB中的index的编号,这个在恢复中非常重要,恢复之时需要根据这个去定位具体的文件<br />
NAME:主要表的index的名字,有PRIMARY 和 普通列的index信息,一般恢复之时我们选择PRIMARY<br />
N_FIELDS:表名index包含列的数量,在mysql恢复中不重要<br />
TYPE:恢复之中使用不到该列,不做说明<br />
PAGE:用途等同SYS_TABLES.SPACE<br />
PAGE_NO:标示为每个index的root page的page号,关于index中的page结构如下图所示<br />
<img src="//www.xifenfei.com/wp-content/uploads/2015/08/Bplustree.png" alt="Bplustree" width="1121" height="516" class="alignleft size-full wp-image-6051" /></p>
<hr />
<strong>SYS_COLUMNS </strong><br />
这个表主要记录数据库中表的列的情况,它存储在index_id 2中.主要用它来确定需要恢复表的列的情况,如果你知道完全的列结构,该表不是MySQL恢复所必须的,它的主要结构为：</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; desc SYS_COLUMNS;
+----------+---------------------+------+-----+---------+-------+
| Field    | Type                | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| TABLE_ID | bigint(20) unsigned | NO   | PRI | NULL    |       | 
| POS      | int(10) unsigned    | NO   | PRI | NULL    |       | 
| NAME     | varchar(255)        | YES  |     | NULL    |       | 
| MTYPE    | int(10) unsigned    | YES  |     | NULL    |       | 
| PRTYPE   | int(10) unsigned    | YES  |     | NULL    |       | 
| LEN      | int(10) unsigned    | YES  |     | NULL    |       | 
| PREC     | int(10) unsigned    | YES  |     | NULL    |       | 
+----------+---------------------+------+-----+---------+-------+
7 rows in set (0.00 sec)
</pre>
<p>TABLE_ID:表标示列,为SYS_TABLES.ID<br />
POS:该列所在表中的位置,该值从0开始<br />
NAME:列的名字<br />
MTYPE 和 PRTYPE:主要是为了记录列的类型,出现此类问题主要是由于InnoDB最初并不是为MySQL而设计,到了后面为更好支持MySQL,因此出现了两种情况.<br />
LEN:列的长度.这个需要注意编码,比如数据库是utf8编码,定义的varchar(10),实际该处长度显示为30,因为每个除英文外的字符编码为3个byte.<br />
PREC:有些特殊类型中,列的精确度定义<br />
<br />
<strong>SYS_FIELDS</strong><br />
记录所有index的列的分布信息,它存储在index_id 4中,该表不是MySQL恢复所必须的,它的主要结构为:</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; desc SYS_FIELDS;
+----------+---------------------+------+-----+---------+-------+
| Field    | Type                | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| INDEX_ID | bigint(20) unsigned | NO   | PRI | NULL    |       | 
| POS      | int(10) unsigned    | NO   | PRI | NULL    |       | 
| COL_NAME | varchar(255)        | YES  |     | NULL    |       | 
+----------+---------------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
</pre>
<p>INDEX_ID:index的标志,等同SYS_INDEXES.ID<br />
POS:列在index中的位置,从0开始<br />
COL_NAME:列的名称<br />
通过上述相关表和列,然后结合MySQL相关恢复工具,就可以从底层在InnoDB出现问题,或者误操作之时提供恢复处理.</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/06/format-disk-mysql-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/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/2011/03/mysql-group-by%e6%93%8d%e4%bd%9c.html" rel="bookmark" class="crp_title">mysql中group by操作</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-delete-%e6%95%b0%e6%8d%ae%e6%81%a2%e5%a4%8d.html" rel="bookmark" class="crp_title">[MySQL异常恢复]mysql delete 数据恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8d%e6%97%a0%e4%b8%bb%e9%94%ae%e6%83%85%e5%86%b5%e4%b8%8binnodb%e6%95%b0%e6%8d%ae%e6%81%a2%e5%a4%8d.html" rel="bookmark" class="crp_title">[MySQL异常恢复]无主键情况下innodb数据恢复</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/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/2025/02/pdu-threshold.html" rel="bookmark" class="crp_title">PostgreSQL恢复工具&#8212;pdu工具介绍</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/05/mysql%e5%88%9b%e5%bb%ba%e5%88%86%e5%8c%ba%e8%a1%a8.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/10/a_h_readme_to_recover.html" rel="bookmark" class="crp_title">A_H_README_TO_RECOVER勒索恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/07/mysql-cluster-7-x%e5%ae%89%e8%a3%85%ef%bc%88windows%ef%bc%89.html" rel="bookmark" class="crp_title">mysql-cluster 7.x安装（windows）</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/05/read_me_recover_tn-recovery.html" rel="bookmark" class="crp_title">read_me_recover_tn勒索恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>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/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
