• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

MySQL异常恢复之无主键情况下innodb数据恢复的方法_MySQL

mysql 搞代码 4年前 (2022-01-09) 36次浏览 已收录 0个评论

本文讲述了MySQL异常恢复之无主键情况下innodb数据恢复的方法。分享给大家供大家参考,具体如下:

在mysql的innodb引擎的数据库异常恢复中,一般都要求有主键或者唯一index,其实这个不是必须的,当没有index信息之时,可以在整个表级别的index_id进行恢复

创建模拟表—无主键

mysql> CREATE TABLE `t1` (  ->  `messageId` varchar(30) character set utf8 NOT NULL,  ->  `tokenId` varchar(20) character set utf8 NOT NULL,  ->  `mobile` varchar(14) character set utf8 default NULL,  ->  `msgFormat` int(1) NOT NULL,  ->  `msgContent` varchar(1000) character set utf8 default NULL,  ->  `scheduleDate` timestamp NOT NULL default '0000-00-00 00:00:00',  ->  `deliverState` int(1) default NULL,  ->  `deliverdTime` timestamp NOT NULL default '0000-00-00 00:00:00'  -> ) ENGINE=INnodb DEFAULT CHARSET=utf8;Query OK, 0 rows affected (0.00 sec)mysql> 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> insert into t1 select * from t1;Query OK, 81664 rows affected (2.86 sec)Records: 81664 Duplicates: 0 Warnings: 0mysql> insert into t1 select * from t1;Query OK, 163328 rows affected (2.74 sec)Records: 163328 Duplicates: 0 Warnings: 0mysql> select count(*) from t1;+----------+| count(*) |+----------+|  326656 | +----------+1 row in set (0.15 sec)

解析innodb文件

[root@web103 mysql_recovery]# rm -rf pages-ibdata1/[root@web103 mysql_recovery]# ./stream_parser -f /var/lib/mysql/ibdata1 Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312time of last access:      1440819443 Sat Aug 29 11:37:23 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312Opening file: /var/lib/mysql/ibdata1File information:time of last access:      1440819443 Sat Aug 29 11:37:23 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015ID of device containing file:     2049inode number:           1344553protection:             100660 time of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312time of last access:      1440819443 Sat Aug 29 11:37:23 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time <b>本文来源gao@!dai!ma.com搞$$代^@码5网@</b>of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)(regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312time of last access:      1440819443 Sat Aug 29 11:37:23 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312time of last access:      1440819443 Sat Aug 29 11:37:23 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312time of last access:      1440819443 Sat Aug 29 11:37:23 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time of last status change:   1440819463 Sat Aug 29 11:37:43 2015Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312total 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 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)Opening file: /var/lib/mysql/ibdata1File information:ID of device containing file:     2049inode number:           1344553protection:             100660 (regular file)number of hard links:          1user ID of owner:            27group ID of owner:           27device ID (if special file):       0blocksize for filesystem I/O:     4096number of blocks allocated:     463312time of last access:      1440819465 Sat Aug 29 11:37:45 2015time of last modification:   1440819463 Sat Aug 29 11:37:43 2015time of last status change:   1440819463 Sat Aug 29 11:37:43 2015total size, in bytes:      236978176 (226.000 MiB)Size to process:         236978176 (226.000 MiB)All workers finished in 0 sec


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:MySQL异常恢复之无主键情况下innodb数据恢复的方法_MySQL
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址