首页 > 数据库 > MySQL > 正文

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

2024-07-24 12:44:56
字体:
来源:转载
供稿:网友

本文讲述了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 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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表