<?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; ERROR 1808 (HY000)</title>
	<atom:link href="https://www.xifenfei.com/tag/error-1808-hy000/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 8.0版本ibd文件恢复</title>
		<link>https://www.xifenfei.com/2022/12/mysql-8-ibd-recovery.html</link>
		<comments>https://www.xifenfei.com/2022/12/mysql-8-ibd-recovery.html#comments</comments>
		<pubDate>Sun, 18 Dec 2022 11:27:18 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[ERROR 1808 (HY000)]]></category>
		<category><![CDATA[ibd恢复]]></category>
		<category><![CDATA[mysql8 ibd恢复]]></category>
		<category><![CDATA[Schema mismatch]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10089</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2022/12/mysql-8-ibd-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/2022/12/mysql-8-ibd-recovery.html" target="_blank">MySQL 8.0版本ibd文件恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>对于单个的ibd文件,大部分情况下可以通过DISCARD TABLESPACE和IMPORT TABLESPACE方式进行恢复</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql&gt; CREATE TABLE `t1` (
    -&gt;   `id` int DEFAULT NULL
    -&gt; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Query OK, 0 rows affected (0.01 sec)
mysql&gt; insert into t1 values(1);
Query OK, 1 row affected (0.02 sec)

mysql&gt; insert into t1 values(2);
Query OK, 1 row affected (0.01 sec)

mysql&gt; insert into t1 values(3);
Query OK, 1 row affected (0.00 sec)
</pre>
<p>关闭mysql服务，备份mysql中的t1.ibd文件</p>
<pre class="brush: bash; title: ; notranslate">
[root@xifenfei ~]# service mysql stop
Shutting down MySQL..... SUCCESS! 
[root@xifenfei test]# cp t1.ibd  t1_bak
</pre>
<p>启动mysql服务,并删除并创建新的t1表(表结构相同)</p>
<pre class="brush: sql; title: ; notranslate">
[root@xifenfei test]# service mysql start
Starting MySQL..................... SUCCESS! 


[root@xifenfei test]# mysql -uroot -poracle test
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql&gt; drop table t1;
Query OK, 0 rows affected (0.20 sec)


mysql&gt; 
mysql&gt; CREATE TABLE `t1` (
    -&gt;   `id` int DEFAULT NULL
    -&gt; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Query OK, 0 rows affected (0.01 sec)
</pre>
<p>DISCARD TABLESPACE操作</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; ALTER TABLE t1 DISCARD TABLESPACE;
Query OK, 0 rows affected (0.01 sec)
</pre>
<p>把备份的t1.ibd还原回去并修改权限</p>
<pre class="brush: bash; title: ; notranslate">
[root@xifenfei test]# mv t1_bak t1.ibd
[root@xifenfei test]# ls -ltr
total 112
-rw-r-----. 1 root root 114688 Dec 18 17:24 t1.ibd
[root@xifenfei test]# chown mysql.mysql t1.ibd 
</pre>
<p>IMPORT TABLESPACE并验证数据</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; ALTER TABLE t1 IMPORT TABLESPACE;
Query OK, 0 rows affected, 1 warning (0.24 sec)

mysql&gt; select * from t1;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)
</pre>
<p>在恢复途中如果遇到表定义不对,或者ibd文件损坏，或者版本不匹配等各种情况,可能在IMPORT TABLESPACE的时候可能出现类似ERROR 1808 (HY000): Schema mismatch (Clustered index validation failed. Because the .cfg file is missing, table definition of the IBD file could be different. Or the data file itself is already corrupted.)错误</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt;  alter table       `t1` import tablespace;                    
ERROR 1808 (HY000): Schema mismatch (Clustered index validation failed. 
Because the .cfg file is missing, table definition of the IBD file could be different. 
Or the data file itself is already corrupted.)
</pre>
<p>如果出现此类错误,无法直接通过该方法进行解决,参考<a href="https://www.xifenfei.com/2021/12/frm-ibm-recovery.html" title="frm和ibd文件数据库恢复" rel="noopener" target="_blank">frm和ibd文件数据库恢复</a>,使用专业恢复工具进行处理</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/07/mysqldumpmysqlbinlog%e6%81%a2%e5%a4%8d%e6%b5%8b%e8%af%95.html" rel="bookmark" class="crp_title">mysqldump+mysqlbinlog恢复测试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/mysql%e6%9f%a5%e8%af%a2%e8%a7%86%e5%9b%be%ef%bc%9aerror-1449-hy000.html" rel="bookmark" class="crp_title">Mysql查询视图：ERROR 1449 (HY000)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/07/mysql-merge%e8%a1%a8.html" rel="bookmark" class="crp_title">Mysql Merge表</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/2011/07/mysql%e5%85%b3%e4%ba%8elog_bin%e7%9b%b8%e5%85%b3%e5%91%bd%e4%bb%a4.html" rel="bookmark" class="crp_title">mysql关于log_bin相关命令</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/2011/07/innobackupex%e5%a2%9e%e9%87%8f%e5%a4%87%e4%bb%bd%e6%b5%8b%e8%af%95.html" rel="bookmark" class="crp_title">innobackupex增量备份测试</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/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/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/2011/09/mysql%e4%b8%bb%e4%bb%8e%e5%88%87%e6%8d%a2.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></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2022/12/mysql-8-ibd-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
