<?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%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>Sun, 22 Nov 2026 15:21:14 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>1.5T MySQL数据库完美恢复</title>
		<link>https://www.xifenfei.com/2026/06/1-5t-mysql-recovery.html</link>
		<comments>https://www.xifenfei.com/2026/06/1-5t-mysql-recovery.html#comments</comments>
		<pubDate>Sat, 06 Jun 2026 03:49:22 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[CLUST_IND]]></category>
		<category><![CDATA[Completing truncate for table]]></category>
		<category><![CDATA[innodb_change_buffer]]></category>
		<category><![CDATA[innodb_force_recovery]]></category>
		<category><![CDATA[log sequence number xxxx is in the future]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=12183</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2026/06/1-5t-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/2026/06/1-5t-mysql-recovery.html" target="_blank">1.5T MySQL数据库完美恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>有客户MySQL数据库异常无法正常启动,需要提供恢复支持,当时提供的错误日志信息为:log sequence number xxxx  is in the future<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2026/06/Q15.png"><img src="https://www.xifenfei.com/wp-content/uploads/2026/06/Q15.png" alt="Q15" width="1187" height="525" class="alignnone size-full wp-image-12184" /></a><br />
<hr />
2026-06-03T13:35:02.368514Z 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.<br />
2026-06-03T13:35:02.369669Z 0 [ERROR] InnoDB: Page [page id: space=0, page number=521127] log sequence number 15319315659882 is in the future! Current system log sequence number 6712970192343.<br />
从头分析mysql的日志，发现最初情况为:</p>
<pre class="brush: bash; title: ; notranslate">
---TRANSACTION 8424429306, ACTIVE 259 sec truncating table
mysql tables in use 1, locked 1
0 lock struct(s), heap size 1136, 0 row lock(s)
MySQL thread id 4513911, OS thread handle 21996, query id 4194188849 localhost 127.0.0.1 root System lock
TRUNCATE TABLE xxxx
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: complete io for buf page (read thread)
I/O thread 3 state: wait Windows aio (read thread)
I/O thread 4 state: wait Windows aio (read thread)
I/O thread 5 state: complete io for buf page (read thread)
I/O thread 6 state: wait Windows aio (write thread)
I/O thread 7 state: wait Windows aio (write thread)
I/O thread 8 state: wait Windows aio (write thread)
I/O thread 9 state: wait Windows aio (write thread)
Pending normal aio reads: [2, 0, 0, 3] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
908141629 OS file reads, 8774070813 OS file writes, 2977363738 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
InnoDB: ###### Diagnostic info printed to the standard error stream
2026-06-03T06:37:25.679003Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 17216 has waited at btr0sea.ic line 128 for 258  seconds the semaphore:
S-lock on RW-latch at 0000017F19122E18 created in file btr0sea.cc line 195
a writer (thread id 8340) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file g:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\include\btr0sea.ic line 90
2026-06-03T06:37:25.681739Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 28160 has waited at btr0sea.ic line 128 for 241  seconds the semaphore:
S-lock on RW-latch at 0000017F19123598 created in file btr0sea.cc line 195
a writer (thread id 13620) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file G:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\btr\btr0cur.cc line 3874
2026-06-03T06:37:25.684495Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 23052 has waited at btr0sea.ic line 128 for 253  seconds the semaphore:
S-lock on RW-latch at 0000017F19123598 created in file btr0sea.cc line 195
a writer (thread id 13620) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file G:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\btr\btr0cur.cc line 3874
2026-06-03T06:37:25.687586Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 28480 has waited at btr0sea.ic line 128 for 272  seconds the semaphore:
S-lock on RW-latch at 0000017F19122E18 created in file btr0sea.cc line 195
a writer (thread id 8340) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file g:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\include\btr0sea.ic line 90
2026-06-03T06:37:25.689857Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 2868 has waited at buf0flu.cc line 1209 for 262  seconds the semaphore:
SX-lock on RW-latch at 00000179B38E0DC0 created in file buf0buf.cc line 1460
a writer (thread id 1008) has reserved it in mode  exclusive
number of readers 0, waiters flag 1, lock_word: f0000000
Last time read locked in file ibuf0ibuf.cc line 4552
Last time write locked in file G:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\ibuf\ibuf0ibuf.cc line 406
…………………………
2026-06-03T06:37:56.919054Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 13620 has waited at btr0sea.ic line 90 for 303  seconds the semaphore:
X-lock (wait_ex) on RW-latch at 0000017F19123598 created in file btr0sea.cc line 195
a writer (thread id 13620) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file G:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\btr\btr0cur.cc line 3874
2026-06-03T06:37:56.921090Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 24268 has waited at btr0sea.ic line 128 for 252  seconds the semaphore:
S-lock on RW-latch at 0000017F19122E18 created in file btr0sea.cc line 195
a writer (thread id 8340) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file g:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\include\btr0sea.ic line 90
2026-06-03T06:37:56.923175Z 0 [Warning] InnoDB: A long semaphore wait:
--Thread 15984 has waited at btr0sea.ic line 128 for 302  seconds the semaphore:
S-lock on RW-latch at 0000017F19122CD8 created in file btr0sea.cc line 195
a writer (thread id 5420) has reserved it in mode  wait exclusive
number of readers 1, waiters flag 1, lock_word: ffffffff
Last time read locked in file btr0sea.ic line 128
Last time write locked in file G:\ade\build\sb_0-34537258-1560180832.84\mysql-5.7.27\storage\innobase\btr\btr0cur.cc line 3874
InnoDB: ###### Starts InnoDB Monitor for 30 secs to print diagnostic info:
InnoDB: Pending preads 0, pwrites 0
InnoDB: ###### Diagnostic info printed to the standard error stream
2026-06-03T07:04:50.616385Z 0 [Note] MySQL: Normal shutdown

2026-06-03T07:04:50.617251Z 0 [Note] Giving 97 client threads a chance to die gracefully
2026-06-03T07:54:31.982035Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use 
--explicit_defaults_for_timestamp server option (see documentation for more details).
2026-06-03T07:54:31.983047Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' 
sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2026-06-03T07:54:31.983057Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2026-06-03T07:54:31.983098Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2026-06-03T07:54:31.985272Z 0 [Note] MySQL (mysqld 5.7.27) starting as process 832 ...
2026-06-03T07:54:32.054771Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2026-06-03T07:54:32.055435Z 0 [Note] InnoDB: Uses event mutexes
2026-06-03T07:54:32.055728Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2026-06-03T07:54:32.056143Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2026-06-03T07:54:32.057581Z 0 [Note] InnoDB: Number of pools: 1
2026-06-03T07:54:32.058963Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2026-06-03T07:54:32.063255Z 0 [Note] InnoDB: Initializing buffer pool, total size = 40G, instances = 8, chunk size = 128M
2026-06-03T07:54:34.619212Z 0 [Note] InnoDB: Completed initialization of buffer pool
2026-06-03T07:54:35.420695Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2026-06-03T07:54:36.121477Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 15319438590791
2026-06-03T07:54:36.449855Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319443833344
2026-06-03T07:54:36.847204Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319449076224
2026-06-03T07:54:37.263455Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319454319104
2026-06-03T07:54:37.544475Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319459561984
2026-06-03T07:54:37.678504Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319463095246
2026-06-03T07:54:37.681262Z 0 [Note] InnoDB: Database was not shutdown normally!
2026-06-03T07:54:37.681755Z 0 [Note] InnoDB: Starting crash recovery.
2026-06-03T07:54:38.088953Z 0 [Note] InnoDB: 2 transaction(s) which must be rolled back or cleaned up in total 1 row operations to undo
2026-06-03T07:54:38.089913Z 0 [Note] InnoDB: Trx id counter is 8424438528
2026-06-03T07:54:38.090288Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 …… 91 92 93 94 95 96 97 98 99 
2026-06-03T07:54:42.043861Z 0 [Note] InnoDB: Apply batch completed
2026-06-03T07:54:42.295726Z 0 [Note] InnoDB: Rolling back trx with id 8424429306, 0 rows to undo
2026-06-03T07:54:42.298212Z 0 [Note] InnoDB: Rollback of trx with id 8424429306 completed
2026-06-03T07:55:19.432722Z 0 [Note] InnoDB: Completing truncate for table with id (8714) residing in file-per-table tablespace with id (6005)
2026-06-03T07:55:30.963664Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90593936, which exceeds the log group capacity 90593280.
2026-06-03T07:55:47.442228Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90602582, which exceeds the log group capacity 90593280.
2026-06-03T07:56:05.422243Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90609452, which exceeds the log group capacity 90593280.
2026-06-03T07:56:27.643550Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90621740, which exceeds the log group capacity 90593280.
2026-06-03T07:56:47.845714Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90627886, which exceeds the log group capacity 90593280.
2026-06-03T07:57:04.714691Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90639662, which exceeds the log group capacity 90593280.
2026-06-03T07:57:26.028889Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90645808, which exceeds the log group capacity 90593280.
2026-06-03T07:57:42.796901Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90655262, which exceeds the log group capacity 90593280.
2026-06-03T07:58:04.513110Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90670384, which exceeds the log group capacity 90593280.
2026-06-03T07:58:20.675070Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90689842, which exceeds the log group capacity 90593280.
2026-06-03T07:58:39.362158Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90699949, which exceeds the log group capacity 90593280.
2026-06-03T07:58:57.146181Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90707243, which exceeds the log group capacity 90593280.
2026-06-03T07:59:15.226281Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90731065, which exceeds the log group capacity 90593280.
2026-06-03T07:59:32.902269Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90751406, which exceeds the log group capacity 90593280.
2026-06-03T07:59:55.020833Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use 
--explicit_defaults_for_timestamp server option (see documentation for more details).
2026-06-03T07:59:55.022839Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' 
sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2026-06-03T07:59:55.022856Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2026-06-03T07:59:55.022918Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2026-06-03T07:59:55.028372Z 0 [Note] MySQL (mysqld 5.7.27) starting as process 2532 ...
2026-06-03T07:59:55.078201Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2026-06-03T07:59:55.078998Z 0 [Note] InnoDB: Uses event mutexes
2026-06-03T07:59:55.079491Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2026-06-03T07:59:55.080092Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2026-06-03T07:59:55.084872Z 0 [Note] InnoDB: Number of pools: 1
2026-06-03T07:59:55.090793Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2026-06-03T07:59:55.096910Z 0 [Note] InnoDB: Initializing buffer pool, total size = 40G, instances = 8, chunk size = 128M
2026-06-03T07:59:57.966267Z 0 [Note] InnoDB: Completed initialization of buffer pool
2026-06-03T07:59:58.778551Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2026-06-03T07:59:59.348188Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 15319447826657
2026-06-03T07:59:59.942491Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319453069312
2026-06-03T08:00:00.233703Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319458312192
2026-06-03T08:00:00.470153Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319463555072
2026-06-03T08:00:01.158338Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319468797952
2026-06-03T08:00:01.852263Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319474040832
2026-06-03T08:00:02.555075Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319479283712
2026-06-03T08:00:03.289043Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319484526592
2026-06-03T08:00:04.031381Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319489769472
2026-06-03T08:00:04.754714Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319495012352
2026-06-03T08:00:05.533650Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319500255232
2026-06-03T08:00:06.253542Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319505498112
2026-06-03T08:00:06.883691Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319510740992
2026-06-03T08:00:07.603988Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319515983872
2026-06-03T08:00:08.268531Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319521226752
2026-06-03T08:00:08.967662Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319526469632
2026-06-03T08:00:09.323566Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 15319529184727
2026-06-03T08:00:09.328240Z 0 [Note] InnoDB: Database was not shutdown normally!
2026-06-03T08:00:09.328844Z 0 [Note] InnoDB: Starting crash recovery.
2026-06-03T08:00:09.730171Z 0 [Note] InnoDB: 1 transaction(s) which must be rolled back or cleaned up in total 1 row operations to undo
2026-06-03T08:00:09.731034Z 0 [Note] InnoDB: Trx id counter is 8424439040
2026-06-03T08:00:09.731402Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 …… 94 95 96 97 98 99 
2026-06-03T08:00:17.587182Z 0 [Note] InnoDB: Apply batch completed
2026-06-03T08:01:02.988241Z 0 [Note] InnoDB: Completing truncate for table with id (8714) residing in file-per-table tablespace with id (6005)
2026-06-03T08:01:07.965314Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90593580, which exceeds the log group capacity 90593280.
2026-06-03T08:01:25.945332Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90599727, which exceeds the log group capacity 90593280.
2026-06-03T08:01:43.117294Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90610481, which exceeds the log group capacity 90593280.
2026-06-03T08:02:05.338558Z 0 [ERROR] InnoDB: The age of the last checkpoint is 90622769, which exceeds the log group capacity 90593280.
</pre>
<p>从这里看，最初是truncate table xxxx,然后由于被阻塞了无法truncate成功,可以就关闭了mysql服务,然后启动库就没有成功,然后就是加上了innodb_force_recovery出现了上述截图的错误.尝试进行强制拉库,遭遇以下错误</p>
<pre class="brush: bash; title: ; notranslate">
2026-06-04T07:05:59.924315Z 0 [Note] MySQL (mysqld 5.7.27) starting as process 8764 ...
2026-06-04T07:05:59.944187Z 0 [Warning] option 'innodb-purge-threads': unsigned value 0 adjusted to 1
2026-06-04T07:05:59.947611Z 0 [Note] InnoDB: Started in read only mode
2026-06-04T07:05:59.948012Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2026-06-04T07:05:59.948485Z 0 [Note] InnoDB: Uses event mutexes
2026-06-04T07:05:59.948825Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2026-06-04T07:05:59.949329Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2026-06-04T07:05:59.950087Z 0 [Note] InnoDB: Number of pools: 1
2026-06-04T07:05:59.950587Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2026-06-04T07:05:59.950987Z 0 [Note] InnoDB: Disabling background log and ibuf IO write threads.
2026-06-04T07:05:59.952835Z 0 [Note] InnoDB: Initializing buffer pool, total size = 512M, instances = 1, chunk size = 128M
2026-06-04T07:05:59.980631Z 0 [Note] InnoDB: Completed initialization of buffer pool
2026-06-04T07:06:00.012856Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2026-06-04T07:06:00.013649Z 0 [Note] InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on, skipping log redo
2026-06-04T07:06:00.019299Z 0 [Note] InnoDB: Completing truncate for table with id (8714) residing in file-per-table tablespace with id (6005)
07:06:00 UTC - mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=200
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 87429 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
7ff67eaba97e    mysqld.exe!std::operator&lt;&lt;&lt;std::char_traits&lt;char&gt; &gt;()[ostream:791]
7ff67f1ffd49    mysqld.exe!os_file_create_subdirs_if_needed()[os0file.cc:2013]
7ff67f22e967    mysqld.exe!fil_ibd_create()[fil0fil.cc:3530]
7ff67f2afdd7    mysqld.exe!truncate_t::fixup_tables_in_non_system_tablespace()[row0trunc.cc:2274]
7ff67f1c563a    mysqld.exe!innobase_start_or_create_for_mysql()[srv0start.cc:2346]
7ff67f12ea40    mysqld.exe!innobase_init()[ha_innodb.cc:4077]
7ff67e9b783e    mysqld.exe!ha_initialize_handlerton()[handler.cc:840]
7ff67eab7228    mysqld.exe!plugin_initialize()[sql_plugin.cc:1229]
7ff67eab8790    mysqld.exe!plugin_register_builtin_and_init_core_se()[sql_plugin.cc:1589]
7ff67e972de3    mysqld.exe!init_server_components()[mysqld.cc:4080]
7ff67e977da5    mysqld.exe!win_main()[mysqld.cc:4773]
7ff67e975705    mysqld.exe!mysql_service()[mysqld.cc:5226]
7ff80e734da7    MSVCR120.dll!_beginthread()
7ff80e734e60    MSVCR120.dll!_endthread()
7ff84e4d84d4    KERNEL32.DLL!BaseThreadInitThunk()
7ff850cb1791    ntdll.dll!RtlUserThreadStart()
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
</pre>
<p>在启动过程中需要去完成truncate操作,但是由于强制拉库是只读状态导致无法完成,直接启动失败.如果非只读状态拉库,启动过程包InnoDB: Corruption of an index tree: table `innodb_change_buffer` index `CLUST_IND`, father ptr page no 111415, child page no 517749异常</p>
<pre class="brush: bash; title: ; notranslate">
2026-06-04T13:35:46.447160Z 0 [ERROR] InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace 
but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html 
for information about forcing recovery.
2026-06-04T13:35:46.448525Z 0 [ERROR] InnoDB: Corruption of an index tree: table `innodb_change_buffer` index `CLUST_IND`, 
father ptr page no 111415, child page no 517749
PHYSICAL RECORD: n_fields 6; 1-byte offsets; info bits 0
 0: len 4; hex 00001775; asc    u;;
 1: len 1; hex 00; asc  ;;
 2: len 4; hex 00e78555; asc    U;;
 3: len 16; hex 000400010c0f0190002d860800088000; asc          -      ;;
 4: len 29; hex 323032362d30332d31345f3132325f315f323032363033313432303136; asc 2026-03-14_122_1_202603142016;;
 5: len 8; hex 800000001b26cad6; asc      &amp;  ;;
2026-06-04T13:35:46.450738Z 0 [Note] InnoDB: n_owned: 0; heap_no: 2; next rec: 211
PHYSICAL RECORD: n_fields 7; 1-byte offsets; info bits 0
 0: len 4; hex 00001775; asc    u;;
 1: len 1; hex 00; asc  ;;
 2: len 4; hex 00e78555; asc    U;;
 3: len 16; hex 000400010c0f0190002d860800088000; asc          -      ;;
 4: len 29; hex 323032362d30332d31345f3132325f315f323032363033313432303136; asc 2026-03-14_122_1_202603142016;;
 5: len 8; hex 800000001b26cad6; asc      &amp;  ;;
 6: len 4; hex 0001b337; asc    7;;
2026-06-04T13:35:46.452647Z 0 [Note] InnoDB: n_owned: 0; heap_no: 147; next rec: 14554
2026-06-04T13:35:46.453038Z 0 [ERROR] [FATAL] InnoDB: You should dump + drop + reimport the table to fix the corruption. 
If the crash happens at database startup. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html 
for information about forcing recovery. Then dump + drop + reimport.
2026-06-04 21:35:46 0x828  InnoDB: Assertion failure in thread 2088 in file ut0ut.cc line 910
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
13:35:46 UTC - mysqld got exception 0x80000003 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=200
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 87429 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
7ff7c7794312    mysqld.exe!my_sigabrt_handler()[my_thr_init.c:449]
7fffaf31ec9d    MSVCR120.dll!raise()
7fffaf324874    MSVCR120.dll!abort()
7ff7c78b07e4    mysqld.exe!ut_dbg_assertion_failed()[ut0dbg.cc:67]
7ff7c78b09c1    mysqld.exe!ib::fatal::~fatal()[ut0ut.cc:910]
7ff7c790a794    mysqld.exe!btr_page_get_father_node_ptr_func()[btr0btr.cc:799]
7ff7c790a28e    mysqld.exe!btr_page_get_father()[btr0btr.cc:854]
7ff7c7906cca    mysqld.exe!btr_compress()[btr0btr.cc:3577]
7ff7c7913a3e    mysqld.exe!btr_cur_compress_if_useful()[btr0cur.cc:5068]
7ff7c7917f7c    mysqld.exe!btr_cur_pessimistic_delete()[btr0cur.cc:5403]
7ff7c79583f9    mysqld.exe!ibuf_delete_rec()[ibuf0ibuf.cc:4385]
7ff7c795805e    mysqld.exe!ibuf_delete_for_discarded_space()[ibuf0ibuf.cc:4833]
7ff7c78d51a8    mysqld.exe!fil_recreate_tablespace()[fil0fil.cc:2265]
7ff7c794fe06    mysqld.exe!truncate_t::fixup_tables_in_non_system_tablespace()[row0trunc.cc:2297]
7ff7c786563a    mysqld.exe!innobase_start_or_create_for_mysql()[srv0start.cc:2346]
7ff7c77cea40    mysqld.exe!innobase_init()[ha_innodb.cc:4077]
7ff7c705783e    mysqld.exe!ha_initialize_handlerton()[handler.cc:840]
7ff7c7157228    mysqld.exe!plugin_initialize()[sql_plugin.cc:1229]
7ff7c7158790    mysqld.exe!plugin_register_builtin_and_init_core_se()[sql_plugin.cc:1589]
7ff7c7012de3    mysqld.exe!init_server_components()[mysqld.cc:4080]
7ff7c7017da5    mysqld.exe!win_main()[mysqld.cc:4773]
7ff7c7015705    mysqld.exe!mysql_service()[mysqld.cc:5226]
7fffaf2d4da7    MSVCR120.dll!_beginthread()
7fffaf2d4e60    MSVCR120.dll!_endthread()
7fffd0f784d4    KERNEL32.DLL!BaseThreadInitThunk()
7fffd3b91791    ntdll.dll!RtlUserThreadStart()
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
</pre>
<p>基于这种两种情况:<br />
2026-06-04T13:35:46.448525Z 0 [ERROR] InnoDB: Corruption of an index tree: table `innodb_change_buffer` index `CLUST_IND`, father ptr page no 111415, child page no 517749和InnoDB: Completing truncate for table with id (8714) residing in file-per-table tablespace with id (6005)异常形成了相互死循环,无法直接强制拉库.<br />
这个库有1.5T如果通过工具提取效率有点低<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2026/06/data.png"><img src="https://www.xifenfei.com/wp-content/uploads/2026/06/data.png" alt="data" width="680" height="387" class="alignnone size-full wp-image-12185" /></a><br />
<hr />
对于这样的情况,使用ibd的discard+import功能进行处理,参考相关文章:<br />
<a href="https://www.xifenfei.com/2021/12/frm-ibm-recovery.html" title="frm和ibd文件数据库恢复" rel="noopener" target="_blank">frm和ibd文件数据库恢复</a><br />
运气不错,这个客户的所有库通过这种方法导入ibd文件（部分temp结尾的临时表数据可以不用恢复,占据空间较大）之后,然后通过mysqldump顺利导出所有数据,完成本次恢复任务<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2026/06/sql.jpg"><img src="https://www.xifenfei.com/wp-content/uploads/2026/06/sql.jpg" alt="sql" width="972" height="352" class="alignnone size-full wp-image-12186" /></a><br />
<hr />
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/07/cannot-open-table-dbtab-from-the-internal-data-dictionary.html" rel="bookmark" class="crp_title">InnoDB: Cannot open table db/tab from the internal data dictionary of InnoDB  though the .frm file for the table exists</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/04/my-013183.html" rel="bookmark" class="crp_title">[MY-013183] [InnoDB] Assertion failure故障处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/mysql%e8%af%af%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae%e5%8f%8a%e5%85%b6bug%e5%88%86%e6%9e%90.html" rel="bookmark" class="crp_title">Mysql误删除数据及其bug分析</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/05/mysql-parameter-error-startup-failed.html" rel="bookmark" class="crp_title">unknown variable &#8216;default-character-set=utf8&#8242; 处理</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/2011/04/innodb%e5%8f%82%e6%95%b0%e7%9a%84%e5%90%ab%e4%b9%89.html" rel="bookmark" class="crp_title">INNODB参数的含义</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/08/redo-corrupt-recovery.html" rel="bookmark" class="crp_title">不太常见的10.2.0.1的oracle redo损坏恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/06/deepseek_oracle_recovery_major_fault.html" rel="bookmark" class="crp_title">使用deepseek进行Oracle恢复,引起重大故障</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/08/obet-forcecopy-ioerror.html" rel="bookmark" class="crp_title">obet forcecopy功能抢救硬件故障中的数据文件</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/09/ora-00354.html" rel="bookmark" class="crp_title">记录一次0丢失的ORA-00354: 损坏重做日志块标头故障恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/04/orafhr-oracle-wman.html" rel="bookmark" class="crp_title">OraFHR快速open被勒索加密破坏的Oracle数据库</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2026/06/1-5t-mysql-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql drop database 恢复思路</title>
		<link>https://www.xifenfei.com/2025/11/mysql-drop-database-recovery.html</link>
		<comments>https://www.xifenfei.com/2025/11/mysql-drop-database-recovery.html#comments</comments>
		<pubDate>Sun, 30 Nov 2025 15:08:16 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[drop database]]></category>
		<category><![CDATA[mysql drop database恢复]]></category>
		<category><![CDATA[mysql数据块扫描]]></category>
		<category><![CDATA[mysql碎片]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=11783</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2025/11/mysql-drop-database-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/11/mysql-drop-database-recovery.html" target="_blank">mysql drop database 恢复思路</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>今天有一个客户在在虚拟机环境中使用drop database删除一个业务mysql的库,删除之后,第一时间关闭了该虚拟机系统.接到该case请求之后,让客户提供了虚拟机文件(vmdk),通过工具分析,mysql数据库是放在/分区下面的/data里面(lvm结构，xfs文件系统),但是已经看不到他们删除的数据库(mysql一个库对应一个目录)<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2025/11/mysql.png"><img src="https://www.xifenfei.com/wp-content/uploads/2025/11/mysql.png" alt="mysql" width="1043" height="297" class="alignleft size-full wp-image-11784" /></a><br />
<hr />
对于这种情况,我们第一步尝试文件系统层面反删除恢复(对数据库所在分区进行文件系统层面扫描,尝试恢复被删除的mysql表文件),运气不错,找到了一些被删除库的ibd文件<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2025/11/ibd.png"><img src="https://www.xifenfei.com/wp-content/uploads/2025/11/ibd.png" alt="ibd" width="1681" height="662" class="alignleft size-full wp-image-11785" /></a><br />
<hr />
对于这些文件,选择出来客户需要的表,采用discard+import方式进行恢复,类似命令</p>
<pre class="brush: bash; title: ; notranslate">
alter table tablename discard tablespace;
alter table tablename import tablespace;
</pre>
<p>对于有些部分block损坏的ibd文件,直接这样操作可能会报Data structure corruption错误,这样的情况,可以通过工具解析ibd文件进行恢复<br />
<img src="https://www.xifenfei.com/wp-content/uploads/2021/12/20211224142855.jpg" width="897" height="648" class="alignleft" /><br />
<hr />
对于有些表,可能在文件系统层面反删除无法恢复,我们通过对磁盘进行mysql的数据块层面扫描(识别在磁盘上没有覆盖的mysql的block),按照pageid的方式进行重组成一个个page文件<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2025/11/page.png"><img src="https://www.xifenfei.com/wp-content/uploads/2025/11/page.png" alt="page" width="792" height="510" class="alignleft size-full wp-image-11786" /></a><br />
<hr />
然后基于这些page进行恢复需要的表数据<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2025/11/11.png"><img src="https://www.xifenfei.com/wp-content/uploads/2025/11/11.png" alt="11" width="1031" height="449" class="alignleft size-full wp-image-11787" /></a><br />
<hr />
基本上通过上述的方法实现最大限度mysql删除数据的恢复(比如drop database，drop table，truncate table)<br />
如果MySQL数据库恢复问题,需要专业恢复技术支持，请联系我们提供<a href="https://www.xifenfei.com/mysql-recovery" title="专业MySql数据库恢复服务" rel="noopener" target="_blank">专业MySql数据库恢复服务</a>:<br />
<strong><font color="red" size=4>电话/微信:17813235971 &nbsp;&nbsp;   Q Q:107644445<a target="_blank" href="https://wpa.qq.com/msgrd?v=3&amp;uin=107644445&amp;site=qq&amp;menu=yes"><img id="xffqqimg" src="//www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"></a>  &nbsp;&nbsp;  E-Mail:dba@xifenfei.com</font></strong></p>
<div id="crp_related"><ul><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/2025/03/vmdk-recovery.html" rel="bookmark" class="crp_title">VMware勒索加密恢复(vmdk勒索恢复)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/10/linux7-8-single-user.html" rel="bookmark" class="crp_title">redhat系列7/8进入单用户模式</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/12/sql-bak-0-lost-data.html" rel="bookmark" class="crp_title">模拟sql server故障备份完成恢复实现数据0丢失</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/03/pg-delete-recovery.html" rel="bookmark" class="crp_title">pg误删除数据恢复（PostgreSQL delete数据恢复）</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/10/makop-recovery.html" rel="bookmark" class="crp_title">.makop加密数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/03/eking-db-recovery.html" rel="bookmark" class="crp_title">.eking扩展名数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/02/globeimposter-alpha666qqz-recovery.html" rel="bookmark" class="crp_title">.Globeimposter-Alpha666qqz加密恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/11/makop-database-recovery.html" rel="bookmark" class="crp_title">.makop加密数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/11/eking-recovery.html" rel="bookmark" class="crp_title">.eking加密数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/03/wman-mysql-recovery.html" rel="bookmark" class="crp_title">.wman扩展名勒索mysql数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2021/10/ransomware-recovery-db-202110.html" rel="bookmark" class="crp_title">最近几种勒索病毒加密数据库可完美恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2025/11/mysql-drop-database-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>应用连接错误,初始化mysql数据库恢复</title>
		<link>https://www.xifenfei.com/2024/09/mysql-init-recovery.html</link>
		<comments>https://www.xifenfei.com/2024/09/mysql-init-recovery.html#comments</comments>
		<pubDate>Mon, 09 Sep 2024 12:09:51 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[mysql碎片]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10978</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2024/09/mysql-init-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/2024/09/mysql-init-recovery.html" target="_blank">应用连接错误,初始化mysql数据库恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>有人在部署一个新网站的时候,写错了配置信息,直接导致原有数据库被清掉,并创建了新库和写入了数据(其实本质就是drop table恢复)<br />
<img src="https://www.xifenfei.com/wp-content/uploads/2024/09/mysql.png" alt="mysql" width="778" height="135" class="alignleft size-full wp-image-10979" /><br />
<hr />
登录操作系统查看,发现数据库文件在根分区,创建了新库,写入了数据之外,还有几个G的binlog.全部恢复不太可能,最后客户决定需要恢复的2个核心表数据,估计也就几十M的数据.通过os层面进行分析,发现操作系统的反删除恢复无法实现这类数据恢复.最后决定从mysql innodb的的碎片级别记性扫描恢复,通过扫描发现较多碎片<br />
<img src="https://www.xifenfei.com/wp-content/uploads/2024/09/page.png" alt="page" width="647" height="616" class="alignleft size-full wp-image-10980" /><br />
<hr />
然后通过一些思路找出来需要恢复的表对应的page文件,然后对其进行解析恢复出来需要的数据<br />
<img src="https://www.xifenfei.com/wp-content/uploads/2024/09/1.png" alt="1" width="1021" height="476" class="alignleft size-full wp-image-10982" /><br />
<hr />
具体技术文章参考:<br />
<a href="https://www.xifenfei.com/2023/12/kettle-lost-mysql-data-recovery.html" title="kettle导致MySQL数据丢失恢复" rel="noopener" target="_blank">kettle导致MySQL数据丢失恢复</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/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/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/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/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/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/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/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/2024/09/drop-tablespace-xxx-including-contents-recovery.html" rel="bookmark" class="crp_title">drop tablespace xxx including contents恢复</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/03/onlybuycyberfear-com-revrac.html" rel="bookmark" class="crp_title">.[OnlyBuy@cyberfear.com].REVRAC勒索mysql恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/09/delete-df-some-overwrit-recovery.html" rel="bookmark" class="crp_title">删除数据库文件并部分覆盖情况下Oracle恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/05/asm-drop-tbs-recovery.html" rel="bookmark" class="crp_title">ASM删除表空间恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/01/dd-asm-recovery.html" rel="bookmark" class="crp_title">在生产环境错误执行dd命令破坏asm磁盘故障恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2024/09/mysql-init-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InnoDB: Database page corruption on disk or a failed file read of page恢复</title>
		<link>https://www.xifenfei.com/2023/02/innodb-database-page-corruption-on-disk-or-a-failed-file-read-of-page.html</link>
		<comments>https://www.xifenfei.com/2023/02/innodb-database-page-corruption-on-disk-or-a-failed-file-read-of-page.html#comments</comments>
		<pubDate>Sun, 12 Feb 2023 04:56:47 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[ibd损坏恢复]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10142</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2023/02/innodb-database-page-corruption-on-disk-or-a-failed-file-read-of-page.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/2023/02/innodb-database-page-corruption-on-disk-or-a-failed-file-read-of-page.html" target="_blank">InnoDB: Database page corruption on disk or a failed file read of page恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>由于文件系统或者硬件故障导致mysql启动报错InnoDB: Database page corruption on disk or a failed file read of page<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2023/02/mysql-error.jpg"><img src="https://www.xifenfei.com/wp-content/uploads/2023/02/mysql-error.jpg" alt="mysql-error" width="1354" height="307" class="alignnone size-full wp-image-10143" /></a><br />
<hr />
使用innodb_force_recovery参数,数据库启动成功,但是部分表查询报错,对于这种情况,是由于ibd文件本身有损坏,通过DISCARD TABLESPACE和IMPORT TABLESPACE也无法解决,只能对ibd文件进行恢复，通过工具直接解析ibd文件恢复其中数据<br />
<a href="https://www.xifenfei.com/wp-content/uploads/2023/02/20230212125347.jpg"><img src="https://www.xifenfei.com/wp-content/uploads/2023/02/20230212125347.jpg" alt="20230212125347" width="1089" height="561" class="alignnone size-full wp-image-10146" /></a><br />
<hr />
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/12/kettle-lost-mysql-data-recovery.html" rel="bookmark" class="crp_title">kettle导致MySQL数据丢失恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/12/mysql-accidental-loss-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/2023/07/ora-01122-ora-01200.html" rel="bookmark" class="crp_title">ORA-01122 ORA-01200故障处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/11/a____z____recover____data.html" rel="bookmark" class="crp_title">A____Z____RECOVER____DATA勒索恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/07/faust-db-recovery.html" rel="bookmark" class="crp_title">.faust加密勒索数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/03/eight-db-recovery.html" rel="bookmark" class="crp_title">.eight加密数据库恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/06/oracle-recovery-tools-csc-higher-than-block-scn.html" rel="bookmark" class="crp_title">Oracle Recovery Tools恢复csc higher than block scn</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/01/imp-00009.html" rel="bookmark" class="crp_title">IMP-00009: abnormal end of export file</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/02/asm-disk-add-vg-extend-lv.html" rel="bookmark" class="crp_title">再一例asm disk被误加入vg并且扩容lv恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/06/mdf-locked-recovery.html" rel="bookmark" class="crp_title">.mdf.locked加密sql server完美恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/01/truncate-sys-table-recovery.html" rel="bookmark" class="crp_title">truncate sys用户表导致数据库异常恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/03/buffer-io-error-on-dev-recovery.html" rel="bookmark" class="crp_title">Buffer I/O error on dev故障数据库恢复</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2023/02/innodb-database-page-corruption-on-disk-or-a-failed-file-read-of-page.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
		<item>
		<title>[MySQL异常恢复]mysql drop table 数据恢复</title>
		<link>https://www.xifenfei.com/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html</link>
		<comments>https://www.xifenfei.com/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html#comments</comments>
		<pubDate>Sat, 29 Aug 2015 14:58:57 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[ibdata恢复]]></category>
		<category><![CDATA[innodb drop 恢复]]></category>
		<category><![CDATA[innodb恢复]]></category>
		<category><![CDATA[mysql drop database恢复]]></category>
		<category><![CDATA[mysql drop恢复]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=6081</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <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">继续阅读 <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%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html" target="_blank">[MySQL异常恢复]mysql drop table 数据恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>对于MySQL数据库的innodb引擎的数据库中,由于误操作删除表,或者由于sqldump自动生成语句含drop table create table语句导致数据丢失,在没有覆盖的情况下,可以实现完美恢复<br />
<strong>创建测试表</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; CREATE TABLE recover.`t_drop` (
    -&gt;   `messageId` varchar(30) NOT NULL,
    -&gt;   `msgContent` varchar(1000) default NULL,
    -&gt;   `scheduleDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
    -&gt;   `deliverState` int(1) default NULL,
    -&gt;   PRIMARY KEY  (`messageId`)
    -&gt; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; insert into recover.t_drop select messageId,msgContent,scheduleDate,deliverState from sms_send_record;
Query OK, 11 rows affected (0.00 sec)
Records: 11  Duplicates: 0  Warnings: 0

mysql&gt; select * from recover.`t_drop`;
+--------------------+----------------------------------------------------------------------------------+---------------------+--------------+
| messageId          | msgContent                                                                       | scheduleDate        | deliverState |
+--------------------+----------------------------------------------------------------------------------+---------------------+--------------+
| 10235259536125650  | 尊敬的用户您好：您的手机验证码为474851如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 10235353811295807  | 尊敬的用户您好：您的手机验证码为444632如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 102354211240398235 | 尊敬的用户您好：您的手机验证码为478503如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 102354554052884567 | 尊敬的用户您好：您的手机验证码为216825如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 132213454294519126 | 尊敬的用户您好：您的手机验证码为854812如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 82329022242584577  | 尊敬的用户您好：您的手机验证码为253127如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 82329022242584581  | 尊敬的用户您好：您的手机验证码为253127如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 8233400415607376   | 尊敬的用户您好：您的手机验证码为338470如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 82334502212106951  | 尊敬的用户您好：您的手机验证码为916515如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 82339012756833423  | 尊敬的用户您好：您的手机验证码为396108如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
| 8234322198577796   | 尊敬的用户您好：您的手机验证码为935297如非本人操作，请拨打奥斯卡客服：400-620-757    | 2010-01-01 00:00:00 |            0 | 
+--------------------+----------------------------------------------------------------------------------+---------------------+--------------+
11 rows in set (0.00 sec)

mysql&gt; checksum table t_drop;
+-----------------+-----------+
| Table           | Checksum  |
+-----------------+-----------+
| recover.t_drop  | 920719058 | 
+-----------------+-----------+
1 row in set (0.00 sec)
</pre>
<p><strong>删除测试表,后续用来恢复</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; drop table recover.t_drop;
Query OK, 0 rows affected (0.00 sec)
</pre>
<p><strong>解析ibdata文件</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# ./stream_parser -f /var/lib/mysql/ibdata1 
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440825416 Sat Aug 29 13:16:56 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440825416 Sat Aug 29 13:16:56 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440825416 Sat Aug 29 13:16:56 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440825416 Sat Aug 29 13:16:56 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440825416 Sat Aug 29 13:16:56 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440825416 Sat Aug 29 13:16:56 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440855928 Sat Aug 29 21:45:28 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440855928 Sat Aug 29 21:45:28 2015
time of last modification:      1440855835 Sat Aug 29 21:43:55 2015
time of last status change:     1440855835 Sat Aug 29 21:43:55 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Worker(1): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(0): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(4): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(3): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(2): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(7): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(5): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
Worker(6): 56.64% done. 2015-08-29 21:45:30 ETA(in 00:00:01). Processing speed: 8.000 MiB/sec
All workers finished in 1 sec
</pre>
<p><strong>恢复mysql字典</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# ./recover_dictionary.sh 
Generating dictionary tables dumps... OK
Creating test database ... OK
Creating dictionary tables in database test:
SYS_TABLES ... OK
SYS_COLUMNS ... OK
SYS_INDEXES ... OK
SYS_FIELDS ... OK
All OK
Loading dictionary tables data:
SYS_TABLES ... 162 recs OK
SYS_COLUMNS ... 1247 recs OK
SYS_INDEXES ... 216 recs OK
SYS_FIELDS ... 411 recs OK
All OK
[root@web103 mysql_recovery]# mysql test
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 10162
Server version: 5.0.95 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

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; select * from SYS_TABLES WHERE name like 'recover%';
+-------------------------+-----+--------+------+--------+---------+--------------+-------+
| NAME                    | ID  | N_COLS | TYPE | MIX_ID | MIX_LEN | CLUSTER_NAME | SPACE |
+-------------------------+-----+--------+------+--------+---------+--------------+-------+
| recover/#sql-64a9_1f6d  | 120 |      8 |    1 |      0 |       0 |              |     0 | 
| recover/#sql2-64a9-1f6d | 115 |      8 |    1 |      0 |       0 |              |     0 | 
| recover/t_delete        |  74 |      2 |    1 |      0 |       0 |              |     0 | 
| recover/t_delete1       |  84 |      2 |    1 |      0 |       0 |              |     0 | 
| recover/t_drop          | 125 |      4 |    1 |      0 |       0 |              |     0 | 
| recover/t_truncate      | 120 |      8 |    1 |      0 |       0 |              |     0 | 
| recover/t_xifenfei      |  75 |      2 |    1 |      0 |       0 |              |     0 | 
| recover/zx_users        |  89 |     85 |    1 |      0 |       0 |              |     0 | 
+-------------------------+-----+--------+------+--------+---------+--------------+-------+
8 rows in set (0.00 sec)

mysql&gt; select * from SYS_INDEXES WHERE TABLE_ID=125;
+----------+-----+---------+----------+------+-------+------------+
| TABLE_ID | ID  | NAME    | N_FIELDS | TYPE | SPACE | PAGE_NO    |
+----------+-----+---------+----------+------+-------+------------+
|      125 | 142 | PRIMARY |        1 |    3 |     0 | 4294967295 | 
+----------+-----+---------+----------+------+-------+------------+
1 row in set (0.00 sec)
</pre>
<p><strong>恢复被删除表记录</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# ./c_parser -5f pages-ibdata1/FIL_PAGE_INDEX/0000000000000142.page  -t dictionary/t_drop.sql &gt;dumps/default/t_drop 2&gt;2.sql
[root@web103 mysql_recovery]# more dumps/default/t_drop
-- Page id: 9860, Format: COMPACT, Records list: Valid, Expected records: (11 11)
00000099F9F2    80000026800110  t_drop  &quot;10235259536125650&quot;     &quot;尊敬的用户您好：您的手机验证码为474851如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    80000026800129  t_drop  &quot;10235353811295807&quot;     &quot;尊敬的用户您好：您的手机验证码为444632如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    80000026800142  t_drop  &quot;102354211240398235&quot;    &quot;尊敬的用户您好：您的手机验证码为478503如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    8000002680015C  t_drop  &quot;102354554052884567&quot;    &quot;尊敬的用户您好：您的手机验证码为216825如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    80000026800176  t_drop  &quot;132213454294519126&quot;    &quot;尊敬的用户您好：您的手机验证码为854812如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    80000026800190  t_drop  &quot;82329022242584577&quot;     &quot;尊敬的用户您好：您的手机验证码为253127如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    800000268001A9  t_drop  &quot;82329022242584581&quot;     &quot;尊敬的用户您好：您的手机验证码为253127如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    800000268001C2  t_drop  &quot;8233400415607376&quot;      &quot;尊敬的用户您好：您的手机验证码为338470如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    800000268001DA  t_drop  &quot;82334502212106951&quot;     &quot;尊敬的用户您好：您的手机验证码为916515如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    800000268001F3  t_drop  &quot;82339012756833423&quot;     &quot;尊敬的用户您好：您的手机验证码为396108如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
00000099F9F2    8000002680020C  t_drop  &quot;8234322198577796&quot;      &quot;尊敬的用户您好：您的手机验证码为935297如非本人操作，请拨打奥斯卡客服：400-620-7575。&quot;  &quot;2010-01-01 00:00:00&quot;   0
-- Page id: 9860, Found records: 11, Lost records: NO, Leaf page: YES
</pre>
<p><strong>恢复数据入库</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; source dictionary/t_drop.sql
Query OK, 0 rows affected (0.00 sec)

mysql&gt; source 2.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 11 rows affected (0.00 sec)
Records: 11  Deleted: 0  Skipped: 0  Warnings: 0

mysql&gt; checksum table t_drop;
+-----------------+-----------+
| Table           | Checksum  |
+-----------------+-----------+
| recover.t_drop  | 920719058 | 
+-----------------+-----------+
1 row in set (0.00 sec)
</pre>
<p>至此实现删除数据完美恢复</p>
<div id="crp_related"><ul><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/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-recovery-support.html" rel="bookmark" class="crp_title">MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)</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/2016/06/oracle-dul-11-released.html" rel="bookmark" class="crp_title">oracle dul 11 正式发布</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/11/dul-support-oracle-7.html" rel="bookmark" class="crp_title">最新版Oracle dul支持Oracle 7.2.3</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/2022/12/mysql-8-ibd-recovery.html" rel="bookmark" class="crp_title">MySQL 8.0版本ibd文件恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/09/10g%e6%96%b0%e5%a2%9e%e5%88%97%e6%96%b9%e5%bc%8f%e6%8c%87%e5%ae%9ahint.html" rel="bookmark" class="crp_title">10g新增列方式指定HINT</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/01/%e8%b7%b3%e8%bf%87obj%e5%9d%8f%e5%9d%97%e6%96%b9%e6%b3%95.html" rel="bookmark" class="crp_title">跳过obj$坏块方法</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/10/exp-00104-datatype-binary_double-%e9%94%99%e8%af%af.html" rel="bookmark" class="crp_title">EXP-00104: datatype (BINARY_DOUBLE) 错误</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2010/08/mysql-%e4%bd%bf%e7%94%a8%e4%ba%8c%e8%bf%9b%e5%88%b6%e6%97%a5%e5%bf%97%e6%96%87%e4%bb%b6%e6%81%a2%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%ba%93.html" rel="bookmark" class="crp_title">mysql 使用二进制日志文件恢复数据库</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[MySQL异常恢复]无主键情况下innodb数据恢复</title>
		<link>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</link>
		<comments>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#comments</comments>
		<pubDate>Sat, 29 Aug 2015 04:35:44 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[innodb恢复]]></category>
		<category><![CDATA[无主键]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=6078</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <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">继续阅读 <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%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" target="_blank">[MySQL异常恢复]无主键情况下innodb数据恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在mysql的innodb引擎的数据库异常恢复中,一般都要求有主键或者唯一index,其实这个不是必须的,当没有index信息之时,可以在整个表级别的index_id进行恢复<br />
<strong>创建模拟表&#8212;无主键</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt;  CREATE TABLE `t1` (
    -&gt;   `messageId` varchar(30) character set utf8 NOT NULL,
    -&gt;   `tokenId` varchar(20) character set utf8 NOT NULL,
    -&gt;   `mobile` varchar(14) character set utf8 default NULL,
    -&gt;   `msgFormat` int(1) NOT NULL,
    -&gt;   `msgContent` varchar(1000) character set utf8 default NULL,
    -&gt;   `scheduleDate` timestamp NOT NULL default '0000-00-00 00:00:00',
    -&gt;   `deliverState` int(1) default NULL,
    -&gt;   `deliverdTime` timestamp NOT NULL default '0000-00-00 00:00:00'
    -&gt; ) ENGINE=INnodb DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; insert into t1 select * from sms_service.sms_send_record;
Query OK, 11 rows affected (0.00 sec)
Records: 11  Duplicates: 0  Warnings: 0
…………
mysql&gt; insert into t1 select * from t1;
Query OK, 81664 rows affected (2.86 sec)
Records: 81664  Duplicates: 0  Warnings: 0

mysql&gt; insert into t1 select * from t1;
Query OK, 163328 rows affected (2.74 sec)
Records: 163328  Duplicates: 0  Warnings: 0

mysql&gt; select count(*) from t1;
+----------+
| count(*) |
+----------+
|   326656 | 
+----------+
1 row in set (0.15 sec)
</pre>
<p><strong>解析innodb文件</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# rm -rf pages-ibdata1/
[root@web103 mysql_recovery]# ./stream_parser -f /var/lib/mysql/ibdata1 
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
Opening file: /var/lib/mysql/ibdata1
File information:

time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
(regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
time of last access:            1440819443 Sat Aug 29 11:37:23 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         463312
time of last access:            1440819465 Sat Aug 29 11:37:45 2015
time of last modification:      1440819463 Sat Aug 29 11:37:43 2015
time of last status change:     1440819463 Sat Aug 29 11:37:43 2015
total size, in bytes:            236978176 (226.000 MiB)

Size to process:                 236978176 (226.000 MiB)
All workers finished in 0 sec
</pre>
<p><strong>恢复数据字典</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# ./recover_dictionary.sh 
Generating dictionary tables dumps... OK
Creating test database ... OK
Creating dictionary tables in database test:
SYS_TABLES ... OK
SYS_COLUMNS ... OK
SYS_INDEXES ... OK
SYS_FIELDS ... OK
All OK
Loading dictionary tables data:
SYS_TABLES ... 48 recs OK
SYS_COLUMNS ... 397 recs OK
SYS_INDEXES ... 67 recs OK
SYS_FIELDS ... 89 recs OK
All OK
</pre>
<p><strong>分析数据字典,找出来index_id</strong><br />
这里需要注意对于没有主键的表恢复,我们对应的类型是GEN_CLUST_INDEX</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; select * from SYS_TABLES where name='test/t1';
+----------------------------------------+-----+-------------+------+--------+---------+--------------+-------+
| NAME                                   | ID  | N_COLS      | TYPE | MIX_ID | MIX_LEN | CLUSTER_NAME | SPACE |
+----------------------------------------+-----+-------------+------+--------+---------+--------------+-------+
| test/t1                                | 100 |           8 |    1 |      0 |       0 |              |     0 | 
+----------------------------------------+-----+-------------+------+--------+---------+--------------+-------+
40 rows in set (0.00 sec)

mysql&gt; SELECT * FROM SYS_INDEXES where table_id=100;
+----------+-----+------------------------------+----------+------+-------+------------+
| TABLE_ID | ID  | NAME                         | N_FIELDS | TYPE | SPACE | PAGE_NO    |
+----------+-----+------------------------------+----------+------+-------+------------+
|      100 | 119 | GEN_CLUST_INDEX              |        0 |    1 |     0 |       2951 | 
+----------+-----+------------------------------+----------+------+-------+------------+
67 rows in set (0.00 sec)
</pre>
<p><strong>恢复数据</strong></p>
<pre class="brush: bash; title: ; notranslate">
root@web103 mysql_recovery]# ./c_parser -5f pages-ibdata1/FIL_PAGE_INDEX/0000000000000119.page  -t dictionary/t1.sql &gt;/tmp/2.txt 2&gt;2.sql
[root@web103 mysql_recovery]# more /tmp/2.txt
-- Page id: 10848, Format: COMPACT, Records list: Valid, Expected records: (73 73)
00000002141B    0000009924F2    80000027133548  t1      &quot;82334502212106951&quot;     &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为916515如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
00000002141C    0000009924F2    80000027133558  t1      &quot;82339012756833423&quot;     &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为396108如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
00000002141D    0000009924F2    80000027133568  t1      &quot;8234322198577796&quot;      &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为935297如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
00000002141E    0000009924F2    80000027133578  t1      &quot;10235259536125650&quot;     &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为474851如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
00000002141F    0000009924F2    80000027133588  t1      &quot;10235353811295807&quot;     &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为444632如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
000000021420    0000009924F2    80000027133598  t1      &quot;102354211240398235&quot;    &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为478503如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
000000021421    0000009924F2    800000271335A8  t1      &quot;102354554052884567&quot;    &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为216825如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
000000021422    0000009924F2    800000271335B8  t1      &quot;132213454294519126&quot;    &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为854812如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;1970-01-01 07:00:00&quot;
000000021423    0000009924F2    800000271335C8  t1      &quot;82329022242584577&quot;     &quot;SDK-BBX-010-18681&quot;     &quot;13718311436&quot;   8       &quot;尊敬的用户您好：您的手机验证码为253127如非本人操作，请拨打奥
斯卡客服：400-620-7575。&quot;       &quot;2010-01-01 00:00:00&quot;   0       &quot;2015-08-26 22:02:17&quot;
…………
[root@web103 mysql_recovery]# cat /tmp/2.txt|grep  -v &quot;Page id:&quot;|wc -l
380731
</pre>
<p>因为没有主键,使得恢复出来记录可能有一些重复,整体而言,可以较为完美的恢复数据</p>
<div id="crp_related"><ul><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-drop-table-recovery.html" rel="bookmark" class="crp_title">[MySQL异常恢复]mysql drop table 数据恢复</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-recovery-support.html" rel="bookmark" class="crp_title">MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)</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/2010/08/fckeditor%e4%bd%bf%e7%94%a8%e8%af%b4%e6%98%8e.html" rel="bookmark" class="crp_title">fckeditor使用说明</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/01/%e8%b7%b3%e8%bf%87obj%e5%9d%8f%e5%9d%97%e6%96%b9%e6%b3%95.html" rel="bookmark" class="crp_title">跳过obj$坏块方法</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/02/%e9%80%9a%e8%bf%87sql%e6%9f%a5%e8%af%a2rman%e5%a4%87%e4%bb%bd%e4%bf%a1%e6%81%af.html" rel="bookmark" class="crp_title">通过sql查询rman备份信息</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2010/09/shell%e7%bc%96%e7%a8%8b%e2%80%94%e2%80%94%e5%9f%ba%e6%9c%ac%e8%af%ad%e6%b3%95.html" rel="bookmark" class="crp_title">shell编程——基本语法</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/08/oracle-12c-dbms_utility-expand_sql_text-%e6%9f%a5%e7%9c%8bsql%e8%a7%86%e5%9b%be%e5%9f%ba%e8%a1%a8.html" rel="bookmark" class="crp_title">ORACLE 12C dbms_utility.expand_sql_text 查看SQL视图基表</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/06/oracle-dul-11-released.html" rel="bookmark" class="crp_title">oracle dul 11 正式发布</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/09/bbed_wrap%e8%84%9a%e6%9c%ac%e8%8e%b7%e5%8f%96%e6%95%b0%e6%8d%ae%e5%9d%97%e5%86%85%e5%ae%b9.html" rel="bookmark" class="crp_title">bbed_wrap脚本获取数据块内容</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/%e5%9c%a8%e7%ba%bf%e9%87%8d%e5%ae%9a%e4%b9%89%e5%8e%9f%e7%90%86%e6%8e%a2%e8%ae%a8.html" rel="bookmark" class="crp_title">在线重定义原理探讨</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>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/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[MySQL异常恢复]mysql delete 数据恢复</title>
		<link>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</link>
		<comments>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#comments</comments>
		<pubDate>Wed, 26 Aug 2015 15:59:29 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[mysql delete恢复]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=6058</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <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">继续阅读 <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%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" target="_blank">[MySQL异常恢复]mysql delete 数据恢复</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在mysql(innodb引擎)中,有些时候犹豫误操作导致表中数据被删除,从而导致不可挽回的损失,本文模拟在数据库被误delete的情况下,实现较为完美删除,当然在实际中可能有少量不覆盖或者无法恢复回来,但是在覆盖不多或者未覆盖的情况下,可以实现绝大多数甚至全部恢复.因此在发生误操作时候,应当第一时间保护现场,尽可能防止复写导致不可挽回的损失.在测试恢复过程中,由于mysql和操作系统编码问题,折腾了很久，感谢<a href="http://www.lunar2013.com" title="Lunar" target="_blank">Lunar</a>的指点<br />
<strong>创建模拟表并插入数据</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; CREATE TABLE `sms_send_record_del` (
    -&gt;   `messageId` varchar(30) NOT NULL,
    -&gt;   `tokenId` varchar(20) NOT NULL,
    -&gt;   `mobile` varchar(14) default NULL,
    -&gt;   `msgFormat` int(1) NOT NULL,
    -&gt;   `msgContent` varchar(1000) default NULL,
    -&gt;   `scheduleDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
    -&gt;   `deliverState` int(1) default NULL,
    -&gt;   `deliverdTime` timestamp NOT NULL default '0000-00-00 00:00:00',
    -&gt;   PRIMARY KEY  (`messageId`)
    -&gt; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; insert into sms_send_record_del select * from sms_send_record;
Query OK, 11 rows affected (0.00 sec)
Records: 11  Duplicates: 0  Warnings: 0

mysql&gt; checksum table sms_send_record_del;
+---------------------------------+------------+
| Table                           | Checksum   |
+---------------------------------+------------+
| sms_service.sms_send_record_del | 2258631583 | 
+---------------------------------+------------+
1 row in set (0.00 sec)

mysql&gt; checksum table sms_send_record;    
+-----------------------------+------------+
| Table                       | Checksum   |
+-----------------------------+------------+
| sms_service.sms_send_record | 2258631583 | 
+-----------------------------+------------+
1 row in set (0.00 sec)
</pre>
<p><img src="//www.xifenfei.com/wp-content/uploads/2015/08/mysql-delete-recovery-1.png" alt="mysql-delete-recovery-1" width="1231" height="240" class="alignleft size-full wp-image-6059" /></p>
<hr />
<strong>确定innodb文件对应位置</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; SHOW VARIABLES LIKE 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ | 
+---------------+-----------------+
1 row in set (0.00 sec)

mysql&gt; SHOW VARIABLES LIKE 'innodb_file_per_table';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF   | 
+-----------------------+-------+
1 row in set (0.00 sec)

mysql&gt; SHOW VARIABLES LIKE 'innodb_data_file_path';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:10M:autoextend | 
+-----------------------+------------------------+
1 row in set (0.00 sec)
</pre>
<p><strong>删除表记录</strong><br />
模拟错误操作,误删除表所有数据</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; delete from sms_send_record_del;
Query OK, 11 rows affected (0.00 sec)
</pre>
<p><strong>解析ibdata1文件</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# ./stream_parser -f /var/lib/mysql/ibdata1 
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
Opening file: /var/lib/mysql/ibdata1
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
File information:

total size, in bytes:            161480704 (154.000 MiB)

ID of device containing file:         2049
Size to process:                 161480704 (154.000 MiB)
Opening file: /var/lib/mysql/ibdata1
File information:

ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
Opening file: /var/lib/mysql/ibdata1
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
File information:

blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
ID of device containing file:         2049
inode number:                      1344553
protection:                         100660 (regular file)
number of hard links:                    1
user ID of owner:                       27
group ID of owner:                      27
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:         315712
time of last access:            1440599559 Wed Aug 26 22:32:39 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
time of last access:            1440601884 Wed Aug 26 23:11:24 2015
time of last modification:      1440601853 Wed Aug 26 23:10:53 2015
time of last status change:     1440601853 Wed Aug 26 23:10:53 2015
total size, in bytes:            161480704 (154.000 MiB)

Size to process:                 161480704 (154.000 MiB)
All workers finished in 0 sec
</pre>
<p><strong>分析数据字典</strong></p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; show tables
    -&gt; ;
+----------------+
| Tables_in_test |
+----------------+
| SYS_COLUMNS    | 
| SYS_FIELDS     | 
| SYS_INDEXES    | 
| SYS_TABLES     | 
+----------------+
4 rows in set (0.00 sec)

mysql&gt; select * from SYS_TABLES;
+----------------------------------------+----+-------------+------+--------+---------+--------------+-------+
| NAME                                   | ID | N_COLS      | TYPE | MIX_ID | MIX_LEN | CLUSTER_NAME | SPACE |
+----------------------------------------+----+-------------+------+--------+---------+--------------+-------+
| recover/t_delete                       | 74 |           2 |    1 |      0 |       0 |              |     0 | 
| recover/t_delete1                      | 84 |           2 |    1 |      0 |       0 |              |     0 | 
| recover/t_xifenfei                     | 75 |           2 |    1 |      0 |       0 |              |     0 | 
| recover/zx_users                       | 89 |          85 |    1 |      0 |       0 |              |     0 | 
| sms_service/sms_send_record            | 36 |           8 |    1 |      0 |       0 |              |     0 | 
| sms_service/sms_send_record_del        | 90 |           8 |    1 |      0 |       0 |              |     0 | 
| SYS_FOREIGN                            | 11 | -2147483644 |    1 |      0 |       0 |              |     0 | 
| SYS_FOREIGN_COLS                       | 12 | -2147483644 |    1 |      0 |       0 |              |     0 | 
| test/SYS_COLUMNS                       | 86 |           7 |    1 |      0 |       0 |              |     0 | 
| test/SYS_FIELDS                        | 88 |           3 |    1 |      0 |       0 |              |     0 | 
| test/SYS_INDEXES                       | 87 |           7 |    1 |      0 |       0 |              |     0 | 
| test/SYS_TABLES                        | 85 |           8 |    1 |      0 |       0 |              |     0 | 
| test/zx_users                          | 43 |          85 |    1 |      0 |       0 |              |     0 | 
| xifenfei/t_delete                      | 44 |           8 |    1 |      0 |       0 |              |     0 | 
| xifenfei/t_xifenfei                    | 59 |           2 |    1 |      0 |       0 |              |     0 | 
+----------------------------------------+----+-------------+------+--------+---------+--------------+-------+
39 rows in set (0.00 sec)

mysql&gt; select * from SYS_INDEXES WHERE TABLE_ID=90;
+----------+-----+---------+----------+------+-------+---------+
| TABLE_ID | ID  | NAME    | N_FIELDS | TYPE | SPACE | PAGE_NO |
+----------+-----+---------+----------+------+-------+---------+
|       90 | 110 | PRIMARY |        1 |    3 |     0 |    2955 | 
+----------+-----+---------+----------+------+-------+---------+
1 row in set (0.00 sec)
</pre>
<p><strong>找回被删除记录</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@web103 mysql_recovery]# ./c_parser -5Df pages-ibdata1/FIL_PAGE_INDEX/0000000000000110.page \
[root@web103 mysql_recovery]#    -t dictionary/sms_send_record_del.sql &gt;/tmp/t_1.txt 2&gt;/tmp/t_1.sql
</pre>
<p><img src="//www.xifenfei.com/wp-content/uploads/2015/08/mysql-delete-recovery-2.png" alt="mysql-delete-recovery-2" width="1838" height="436" class="alignleft size-full wp-image-6060" /></p>
<hr />
加载数据并验证</p>
<pre class="brush: sql; title: ; notranslate">
mysql&gt; use sms_service;
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; source /tmp/t_1.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 11 rows affected, 8 warnings (0.01 sec)
Records: 11  Deleted: 0  Skipped: 0  Warnings: 8

mysql&gt; checksum table sms_send_record_del;
+---------------------------------+------------+
| Table                           | Checksum   |
+---------------------------------+------------+
| sms_service.sms_send_record_del | 2258631583 | 
+---------------------------------+------------+
1 row in set (0.00 sec)
</pre>
<p>发生误操作之时,请尽可能保护现场,防止覆盖导致无可挽回的损失.</p>
<div id="crp_related"><ul><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/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html" rel="bookmark" class="crp_title">[MySQL异常恢复]mysql drop table 数据恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/08/mysql-recovery-support.html" rel="bookmark" class="crp_title">MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)</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/2022/12/mysql-8-ibd-recovery.html" rel="bookmark" class="crp_title">MySQL 8.0版本ibd文件恢复</a></li><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/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/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/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/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/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/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></ul></div>]]></content:encoded>
			<wfw:commentRss>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/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
		<item>
		<title>MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)</title>
		<link>https://www.xifenfei.com/2015/08/mysql-recovery-support.html</link>
		<comments>https://www.xifenfei.com/2015/08/mysql-recovery-support.html#comments</comments>
		<pubDate>Fri, 21 Aug 2015 10:10:18 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[MySQL恢复]]></category>
		<category><![CDATA[ibdata1 恢复]]></category>
		<category><![CDATA[mysql delete 恢复]]></category>
		<category><![CDATA[mysql drop database恢复]]></category>
		<category><![CDATA[mysql drop table 恢复]]></category>
		<category><![CDATA[mysql truncate 恢复]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=6043</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2015/08/mysql-recovery-support.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-recovery-support.html" target="_blank">MySQL drop database恢复(恢复方法同样适用MySQL drop table,delete,truncate table)</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>昨天晚上接到一个网络服务请求，由于不小心点击了自己产品软件上面的清空数据功能(这个工具确实需要小心,在Oracle恢复案例中,也有xx企业erp该功能导致数据被删除请求恢复)，导致MySQL数据库被直接drop database掉了，之前没有做任何备份，只是发生故障之后，他们立即封存现场，备份出来了ibdata1文件。接到请求之后，通过让其把ibdata1文件发给过来，通过MySQL recovery工具进行分析恢复，经过6个小时的处理，基本上实现核心数据0丢失.<br />
<strong>解析ibdata1(innodb文件)</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@localhost recovery_MySQL]# ./stream_parser -f /tmp/ibdata1
Opening file: /tmp/ibdata1
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
Opening file: /tmp/ibdata1
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
File information:

time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
ID of device containing file:         2055
inode number:                        97257
protection:                         100644 total size, in bytes:             18874368 (18.000 MiB)

(regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
Size to process:                  18874368 (18.000 MiB)
Opening file: /tmp/ibdata1
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
total size, in bytes:             18874368 (18.000 MiB)

Opening file: /tmp/ibdata1
File information:

Size to process:                  18874368 (18.000 MiB)
ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
number of hard links:                    1
user ID of owner:                        0
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
group ID of owner:                       0
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
total size, in bytes:             18874368 (18.000 MiB)

Size to process:                  18874368 (18.000 MiB)
Opening file: /tmp/ibdata1
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
group ID of owner:                       0
device ID (if special file):             0
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
blocksize for filesystem I/O:         4096
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
number of blocks allocated:          36920
Opening file: /tmp/ibdata1
total size, in bytes:             18874368 (18.000 MiB)

File information:

Size to process:                  18874368 (18.000 MiB)
ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
blocksize for filesystem I/O:         4096
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
number of blocks allocated:          36920
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
Opening file: /tmp/ibdata1
total size, in bytes:             18874368 (18.000 MiB)

File information:

Size to process:                  18874368 (18.000 MiB)
ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
Opening file: /tmp/ibdata1
File information:

total size, in bytes:             18874368 (18.000 MiB)

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 Size to process:                  18874368 (18.000 MiB)
(regular file)
number of hard links:                    1
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
user ID of owner:                        0
group ID of owner:                       0
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
Opening file: /tmp/ibdata1
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
device ID (if special file):             0
File information:

blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
total size, in bytes:             18874368 (18.000 MiB)

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
Size to process:                  18874368 (18.000 MiB)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
Opening file: /tmp/ibdata1
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
File information:

time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
ID of device containing file:         2055
total size, in bytes:             18874368 (18.000 MiB)

inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
Size to process:                  18874368 (18.000 MiB)
group ID of owner:                       0
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
device ID (if special file):             0
blocksize for filesystem I/O:         4096
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
number of blocks allocated:          36920
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
total size, in bytes:             18874368 (18.000 MiB)

Opening file: /tmp/ibdata1
Size to process:                  18874368 (18.000 MiB)
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
user ID of owner:                        0
group ID of owner:                       0
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
device ID (if special file):             0
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
total size, in bytes:             18874368 (18.000 MiB)

Size to process:                  18874368 (18.000 MiB)
Opening file: /tmp/ibdata1
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
device ID (if special file):             0
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
blocksize for filesystem I/O:         4096
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
number of blocks allocated:          36920
total size, in bytes:             18874368 (18.000 MiB)

Opening file: /tmp/ibdata1
File information:

Size to process:                  18874368 (18.000 MiB)
ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
total size, in bytes:             18874368 (18.000 MiB)

Opening file: /tmp/ibdata1
File information:

Size to process:                  18874368 (18.000 MiB)
ID of device containing file:         2055
inode number:                        97257
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
protection:                         100644 (regular file)
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
number of hard links:                    1
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
total size, in bytes:             18874368 (18.000 MiB)

number of blocks allocated:          36920
Size to process:                  18874368 (18.000 MiB)
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
total size, in bytes:             18874368 (18.000 MiB)

Size to process:                  18874368 (18.000 MiB)
Opening file: /tmp/ibdata1
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
total size, in bytes:             18874368 (18.000 MiB)

Size to process:                  18874368 (18.000 MiB)
Opening file: /tmp/ibdata1
File information:

ID of device containing file:         2055
inode number:                        97257
protection:                         100644 (regular file)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       0
device ID (if special file):             0
blocksize for filesystem I/O:         4096
number of blocks allocated:          36920
time of last access:            1440083236 Thu Aug 20 23:07:16 2015
time of last modification:      1440062236 Thu Aug 20 17:17:16 2015
time of last status change:     1440081904 Thu Aug 20 22:45:04 2015
total size, in bytes:             18874368 (18.000 MiB)

Size to process:                  18874368 (18.000 MiB)
All workers finished in 0 sec

[root@localhost recovery_MySQL]# cd pages-ibdata1
[root@localhost pages-ibdata1]# ls -l
total 16
drwxr-xr-x 2 root root 4096 Aug 20 22:53 FIL_PAGE_INDEX
drwxr-xr-x 2 root root 4096 Aug 20 22:53 FIL_PAGE_TYPE_BLOB
[root@localhost pages-ibdata1]# cd FIL_PAGE_INDEX
[root@localhost FIL_PAGE_INDEX]# ls -l
total 9924
-rw-r--r-- 1 root root   32768 Aug 20 22:53 0000000000000001.page
-rw-r--r-- 1 root root  278528 Aug 20 22:53 0000000000000002.page
-rw-r--r-- 1 root root   32768 Aug 20 22:53 0000000000000003.page
-rw-r--r-- 1 root root   32768 Aug 20 22:53 0000000000000004.page
-rw-r--r-- 1 root root   32768 Aug 20 22:53 0000000000000005.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000011.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000012.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000013.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000014.page
-rw-r--r-- 1 root root 2883584 Aug 20 22:53 0000000000000065.page
-rw-r--r-- 1 root root  475136 Aug 20 22:53 0000000000000066.page
-rw-r--r-- 1 root root  737280 Aug 20 22:53 0000000000000067.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000068.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000069.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000070.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000071.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000072.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000073.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000074.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000075.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000076.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 0000000000000077.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000078.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000079.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000080.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000081.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000082.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000083.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000084.page
-rw-r--r-- 1 root root  753664 Aug 20 22:53 0000000000000085.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000086.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000087.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000088.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000089.page
-rw-r--r-- 1 root root  901120 Aug 20 22:53 0000000000000110.page
-rw-r--r-- 1 root root 2097152 Aug 20 22:53 0000000000000115.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000116.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000117.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000118.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000119.page
-rw-r--r-- 1 root root   49152 Aug 20 22:53 0000000000000120.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000121.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000122.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000123.page
-rw-r--r-- 1 root root   98304 Aug 20 22:53 0000000000000124.page
-rw-r--r-- 1 root root   16384 Aug 20 22:53 18446744069414584320.page
[root@localhost FIL_PAGE_INDEX]# 
</pre>
<p><strong>分析数据字典</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@localhost recovery_MySQL]# ./recover_dictionary.sh

Generating dictionary tables dumps... OK
Creating test database ... Warning: Using a password on the command line interface can be insecure.
OK
Creating dictionary tables in database test:
SYS_TABLES ... Warning: Using a password on the command line interface can be insecure.
OK
SYS_COLUMNS ... Warning: Using a password on the command line interface can be insecure.
OK
SYS_INDEXES ... Warning: Using a password on the command line interface can be insecure.
OK
SYS_FIELDS ... Warning: Using a password on the command line interface can be insecure.
OK
All OK
Loading dictionary tables data:
SYS_TABLES ... Warning: Using a password on the command line interface can be insecure.
34 recs OK
SYS_COLUMNS ... Warning: Using a password on the command line interface can be insecure.
3061 recs OK
SYS_INDEXES ... Warning: Using a password on the command line interface can be insecure.
206 recs OK
SYS_FIELDS ... Warning: Using a password on the command line interface can be insecure.
206 recs OK
All OK
</pre>
<p>关于MySQL数据字典恢复,也可以参考另外一篇文章:<a href="//www.xifenfei.com/?p=5669" title="使用工具直接抽取MySQL数据字典" target="_blank">使用工具直接抽取MySQL数据字典</a><br />
<br />
<strong>查看数据库中记录情况</strong></p>
<pre class="brush: sql; title: ; notranslate">
[root@localhost recovery_MySQL]# MySQL -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 34954
Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

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; 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; show tables;
+----------------+
| Tables_in_test |
+----------------+
| SYS_COLUMNS    |
| SYS_FIELDS     |
| SYS_INDEXES    |
| SYS_TABLES     |
+----------------+
4 rows in set (0.00 sec)

MySQL&gt; SELECT NAME,ID from SYS_TABLES;
+-------------------------+----+
| NAME                    | ID |
+-------------------------+----+
| cnywmcom/zx_account_log | 31 |
| cnywmcom/zx_area_code   | 32 |
| cnywmcom/zx_goods_group | 33 |
| cnywmcom/zx_manage_type | 34 |
| cnywmcom/zx_order_goods | 35 |
| cnywmcom/zx_order_info  | 36 |
| cnywmcom/zx_param       | 37 |
| cnywmcom/zx_users       | 46 |
| cnywmcom/zx_user_type   | 38 |
| SYS_FOREIGN             | 11 |
| SYS_FOREIGN_COLS        | 12 |
+-------------------------+----+
11 rows in set (0.00 sec)

MySQL&gt; select * from SYS_INDEXES;
+----------+-----+-----------------+----------+------+-------+---------+
| TABLE_ID | ID  | NAME            | N_FIELDS | TYPE | SPACE | PAGE_NO |
+----------+-----+-----------------+----------+------+-------+---------+
|       11 |  11 | ID_IND          |        1 |    3 |     0 |      46 |
|       11 |  12 | FOR_IND         |        1 |    0 |     0 |      47 |
|       11 |  13 | REF_IND         |        1 |    0 |     0 |      48 |
|       12 |  14 | ID_IND          |        2 |    3 |     0 |      49 |
|       31 |  65 | PRIMARY         |        1 |    3 |     0 |      50 |
|       31 |  66 | user_id         |        1 |    0 |     0 |     216 |
|       32 |  67 | PRIMARY         |        1 |    3 |     0 |      52 |
|       33 |  68 | PRIMARY         |        1 |    3 |     0 |     205 |
|       34 |  69 | PRIMARY         |        1 |    3 |     0 |      54 |
|       35 |  70 | PRIMARY         |        1 |    3 |     0 |      55 |
|       35 |  71 | order_id        |        1 |    0 |     0 |      56 |
|       35 |  72 | goods_id        |        1 |    0 |     0 |      57 |
|       36 |  73 | PRIMARY         |        1 |    3 |     0 |      59 |
|       36 |  74 | order_sn        |        1 |    2 |     0 |      60 |
|       36 |  75 | user_id         |        1 |    0 |     0 |      61 |
|       36 |  76 | order_status    |        1 |    0 |     0 |      62 |
|       36 |  77 | shipping_status |        1 |    0 |     0 |      63 |
|       36 |  78 | pay_status      |        1 |    0 |     0 |     192 |
|       36 |  79 | shipping_id     |        1 |    0 |     0 |     193 |
|       36 |  80 | pay_id          |        1 |    0 |     0 |     194 |
|       36 |  81 | extension_code  |        2 |    0 |     0 |     195 |
|       36 |  82 | agency_id       |        1 |    0 |     0 |     203 |
|       37 |  83 | PRIMARY         |        1 |    3 |     0 |     196 |
|       38 |  84 | PRIMARY         |        1 |    3 |     0 |     206 |
|       46 | 120 | PRIMARY         |        1 |    3 |     0 |      58 |
|       46 | 121 | user_name       |        1 |    2 |     0 |     256 |
|       46 | 122 | email           |        1 |    0 |     0 |     257 |
|       46 | 123 | parent_id       |        1 |    0 |     0 |     258 |
|       46 | 124 | flag            |        1 |    0 |     0 |     259 |
+----------+-----+-----------------+----------+------+-------+---------+
29 rows in set (0.00 sec)
</pre>
<p>通过这里，我们就可以明确的知道，我们需要恢复的表的page是多少了，这里举例说明恢复表cnywmcom.zx_account_log,我们需要去分析65号page<br />
<br />
<strong>分析表恢复</strong></p>
<pre class="brush: bash; title: ; notranslate">
[root@localhost recovery_MySQL]# ./c_parser -5f pages-ibdata1/FIL_PAGE_INDEX/0000000000000065.page -t dictionary/zx_account_log.sql|more
-- Page id: 223, Format: COMPACT, Records list: Invalid, Expected records: (0 7)
0B0C2000101C    55000230000000  zx_account_log  2979181 270888  &quot;0&quot;0&quot;0.00&quot;      &quot;0.00&quot;  &quot;0.00&quot;  2147483649      &quot;&quot;      0       &quot;&quot;      &quot;0.00&quot;  &quot;-10643256.27&quot;  &quot;06.&quot;   &quot;06.&quot;   &quot;0782
7251.51&quot;        &quot;0.5&quot;   &quot;0.5&quot;   &quot;0.5&quot;   &quot;0.5&quot;
000000042228    00000001040135  zx_account_log  561     1       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;1.00&quot;  &quot;0.00&quot;  1436840718      &quot;会员注册&quot;      99      &quot;13818289939&quot;   &quot;1.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00
&quot;       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;
000000042228    0000000104015A  zx_account_log  562     136     &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;1.00&quot;  &quot;0.00&quot;  1436841067      &quot;会员注册&quot;      99      &quot;17828025855&quot;   &quot;1.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00
&quot;       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;
000000042228    0000000104017F  zx_account_log  563     137     &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;1.00&quot;  &quot;0.00&quot;  1436842239      &quot;会员注册&quot;      99      &quot;18617157667&quot;   &quot;1.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00
&quot;       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;
000000042228    000000010401A4  zx_account_log  564     139     &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;1.00&quot;  &quot;0.00&quot;  1436846738      &quot;会员注册&quot;      99      &quot;18113070688&quot;   &quot;1.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00
&quot;       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;
000000042228    000000010401C9  zx_account_log  565     1       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;1.00&quot;  &quot;0.00&quot;  1436848523      &quot;会员注册&quot;      99      &quot;13623646573&quot;   &quot;1.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00
&quot;       &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;  &quot;0.00&quot;
</pre>
<p>至此该表的数据已经恢复出来,剩下任务就是把数据保存为文件,并且导入到新库中.然后依次处理相关表.至此完成这次drop database的恢复.在恢复过程中,遇到不少坑,比如有些记录在对应的page中无法找到,需要进行额外处理.对于乱码问题需要进一步处理等.通过一系列的恢复,给客户恢复了所有核心表,实现核心数据0丢失.通过这次的恢复,已经证明我们不光是Oracle恢复中的行业强者,在MySQL数据库的各种故障中,我们也有立足之地.如果有MySQL数据库的恢复(误删除数据/delete,误删除表/drop table,误截断表/truncate table,误删除数据库/drop database,MySQL不能启动,ibdata1文件损坏/丢失等MySQL各种恢复)请求,如果您遇到MySQL恢复问题无法自行解决,请联系我们提供专业服务,最大程度减小您的损失：<br />
<br />
<strong><span style="color: red; font-size: large;">Phone:17813235971    Q Q:<a href="https://wpa.qq.com/msgrd?v=3&amp;uin=107644445&amp;site=qq&amp;menu=yes" target="_blank">107644445</a>    E-Mail:dba@xifenfei.com</span></strong></p>
<div id="crp_related"><ul><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/2015/08/mysql%e5%bc%82%e5%b8%b8%e6%81%a2%e5%a4%8dmysql-drop-table-recovery.html" rel="bookmark" class="crp_title">[MySQL异常恢复]mysql drop table 数据恢复</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/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/2012/03/gzexe%e5%8a%a0%e5%af%86shell%e8%84%9a%e6%9c%ac.html" rel="bookmark" class="crp_title">gzexe加密shell脚本</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/08/linux-7-udev.html" rel="bookmark" class="crp_title">linux 7(redhat,oracle linux,centos)中使用udev</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2014/01/multipath%e5%ae%9e%e7%8e%b0%e8%ae%be%e5%a4%87%e7%94%a8%e6%88%b7%e7%bb%84%e8%ae%be%e7%bd%ae.html" rel="bookmark" class="crp_title">multipath实现设备用户组设置</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2016/06/oracle-dul-11-released.html" rel="bookmark" class="crp_title">oracle dul 11 正式发布</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/12/olr%e7%9b%b8%e5%85%b3%e7%bb%b4%e6%8a%a4.html" rel="bookmark" class="crp_title">OLR相关维护</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/03/%e5%88%b6%e4%bd%9cu%e7%9b%98%e5%88%b7exadata.html" rel="bookmark" class="crp_title">制作U盘刷EXADATA</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/01/%e8%b7%b3%e8%bf%87obj%e5%9d%8f%e5%9d%97%e6%96%b9%e6%b3%95.html" rel="bookmark" class="crp_title">跳过obj$坏块方法</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/02/%e9%80%9a%e8%bf%87sql%e6%9f%a5%e8%af%a2rman%e5%a4%87%e4%bb%bd%e4%bf%a1%e6%81%af.html" rel="bookmark" class="crp_title">通过sql查询rman备份信息</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2015/08/mysql-recovery-support.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
