未刪除的表結構從ibdata1檔案進行恢復
上節說到對於刪除的表結構進行恢復,這次講對於未刪除的表結構進行恢復:
http://blog.sina.com.cn/s/blog_5037eacb0102vq2n.html
如果因為一些原因,庫打不開了,使用recover引數為6同樣也打不開。
這時只有.ibdata檔案可以用了,可以在Ibdata檔案中抽出表的定義語句
場景:
create database song1;
create table song1(id int,name varchar(10));
insert into song1 values (8,'song');
關閉資料庫,把ibdata1檔案拷貝到安裝了undrop-for-innodb機器的/tmp目錄下:
開始恢復:
[root@10-4-1-104 ]# ./stream_parser -f /tmp/ibdata1
Opening file: /tmp/ibdata1
File information:
ID of device containing file: 64513
inode number: 658133
protection: 100640 (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
Opening file: /tmp/ibdata1
number of blocks allocated: 204800
File information:
ID of device containing file: 64513
inode number: 658133
protection: 100640 (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: 204800
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
Opening file: /tmp/ibdata1
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
total size, in bytes: 104857600 (100.000 MiB)
File information:
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
Size to process: 104857600 (100.000 MiB)
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
ID of device containing file: 64513
inode number: 658133
protection: 100640 (regular file)
number of hard links: 1
user ID of owner: 0
total size, in bytes: 104857600 (100.000 MiB)
group ID of owner: 0
device ID (if special file): 0
blocksize for filesystem I/O: 4096
number of blocks allocated: 204800
Size to process: 104857600 (100.000 MiB)
Opening file: /tmp/ibdata1
File information:
ID of device containing file: 64513
inode number: 658133
protection: 100640 (regular file)
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
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: 204800
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
total size, in bytes: 104857600 (100.000 MiB)
Size to process: 104857600 (100.000 MiB)
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
total size, in bytes: 104857600 (100.000 MiB)
Size to process: 104857600 (100.000 MiB)
All workers finished in 0 sec
[root@10-4-1-104 ]# mkdir -p dumps/default
這裡沒有加上 -D 是因為這個表沒有刪除。
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000001.page \
> -t dictionary/SYS_TABLES.sql \
> > dumps/default/SYS_TABLES \
> 2> dumps/default/SYS_TABLES.sql
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000003.page \
> -t dictionary/SYS_INDEXES.sql \
> > dumps/default/SYS_INDEXES \
> 2> dumps/default/SYS_INDEXES.sql
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000002.page \
> -t dictionary/SYS_COLUMNS.sql \
> > dumps/default/SYS_COLUMNS \
> 2> dumps/default/SYS_COLUMNS.sql
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000004.page \
> -t dictionary/SYS_FIELDS.sql \
> > dumps/default/SYS_FIELDS \
> 2> dumps/default/SYS_FIELDS.sql
在當前機的庫中加上 song1_recover資料庫:
然後:
[root@10-4-1-104 ]# cat dictionary/SYS_* | mysql -u sla -h 10.4.1.104 -psla -D song1_recover
[root@10-4-1-104 ]# cat dumps/default/*.sql | mysql -u sla -h 10.4.1.104 -psla -D song1_recover --local-infile=1
[root@10-4-1-104 ]# make sys_parser
/opt/udb/program/mysql/mysql-5.5.24/bin/mysql_config
cc `mysql_config --cflags` `mysql_config --libs` -o sys_parser sys_parser.c
[root@10-4-1-104 ]# ./sys_parser -u sla -p sla -h 10.4.1.104 -d song_recover song1/song1
./sys_parser: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@10-4-1-104 ]# source /etc/pfrofile
-bash: /etc/pfrofile: No such file or directory
[root@10-4-1-104 ]# source /etc/profile
[root@10-4-1-104 ]# ./sys_parser -u sla -p sla -h 10.4.1.104 -d song_recover song1/song1
Error: Unknown database 'song_recover'
[root@10-4-1-104 ]# ./sys_parser -u sla -p sla -h 10.4.1.104 -d song1_recover song1/song1
CREATE TABLE `song1`(
`id` INT,
WARNING: Fields are not found for table 'song1/song1' in SYS_FIELDS
`name` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci') ENGINE=InnoDB;
[root@10-4-1-104 ]#
轉載請註明源出處
QQ 273002188 歡迎一起學習
http://blog.sina.com.cn/s/blog_5037eacb0102vq2n.html
如果因為一些原因,庫打不開了,使用recover引數為6同樣也打不開。
這時只有.ibdata檔案可以用了,可以在Ibdata檔案中抽出表的定義語句
場景:
create database song1;
create table song1(id int,name varchar(10));
insert into song1 values (8,'song');
關閉資料庫,把ibdata1檔案拷貝到安裝了undrop-for-innodb機器的/tmp目錄下:
開始恢復:
[root@10-4-1-104 ]# ./stream_parser -f /tmp/ibdata1
Opening file: /tmp/ibdata1
File information:
ID of device containing file: 64513
inode number: 658133
protection: 100640 (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
Opening file: /tmp/ibdata1
number of blocks allocated: 204800
File information:
ID of device containing file: 64513
inode number: 658133
protection: 100640 (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: 204800
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
Opening file: /tmp/ibdata1
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
total size, in bytes: 104857600 (100.000 MiB)
File information:
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
Size to process: 104857600 (100.000 MiB)
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
ID of device containing file: 64513
inode number: 658133
protection: 100640 (regular file)
number of hard links: 1
user ID of owner: 0
total size, in bytes: 104857600 (100.000 MiB)
group ID of owner: 0
device ID (if special file): 0
blocksize for filesystem I/O: 4096
number of blocks allocated: 204800
Size to process: 104857600 (100.000 MiB)
Opening file: /tmp/ibdata1
File information:
ID of device containing file: 64513
inode number: 658133
protection: 100640 (regular file)
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
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: 204800
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
total size, in bytes: 104857600 (100.000 MiB)
Size to process: 104857600 (100.000 MiB)
time of last access: 1436975508 Wed Jul 15 23:51:48 2015
time of last modification: 1436975508 Wed Jul 15 23:51:48 2015
time of last status change: 1436975508 Wed Jul 15 23:51:48 2015
total size, in bytes: 104857600 (100.000 MiB)
Size to process: 104857600 (100.000 MiB)
All workers finished in 0 sec
[root@10-4-1-104 ]# mkdir -p dumps/default
這裡沒有加上 -D 是因為這個表沒有刪除。
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000001.page \
> -t dictionary/SYS_TABLES.sql \
> > dumps/default/SYS_TABLES \
> 2> dumps/default/SYS_TABLES.sql
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000003.page \
> -t dictionary/SYS_INDEXES.sql \
> > dumps/default/SYS_INDEXES \
> 2> dumps/default/SYS_INDEXES.sql
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000002.page \
> -t dictionary/SYS_COLUMNS.sql \
> > dumps/default/SYS_COLUMNS \
> 2> dumps/default/SYS_COLUMNS.sql
[root@10-4-1-104 ]# ./c_parser -4f pages-ibdata1/FIL_PAGE_INDEX/0000000000000004.page \
> -t dictionary/SYS_FIELDS.sql \
> > dumps/default/SYS_FIELDS \
> 2> dumps/default/SYS_FIELDS.sql
在當前機的庫中加上 song1_recover資料庫:
然後:
[root@10-4-1-104 ]# cat dictionary/SYS_* | mysql -u sla -h 10.4.1.104 -psla -D song1_recover
[root@10-4-1-104 ]# cat dumps/default/*.sql | mysql -u sla -h 10.4.1.104 -psla -D song1_recover --local-infile=1
[root@10-4-1-104 ]# make sys_parser
/opt/udb/program/mysql/mysql-5.5.24/bin/mysql_config
cc `mysql_config --cflags` `mysql_config --libs` -o sys_parser sys_parser.c
[root@10-4-1-104 ]# ./sys_parser -u sla -p sla -h 10.4.1.104 -d song_recover song1/song1
./sys_parser: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@10-4-1-104 ]# source /etc/pfrofile
-bash: /etc/pfrofile: No such file or directory
[root@10-4-1-104 ]# source /etc/profile
[root@10-4-1-104 ]# ./sys_parser -u sla -p sla -h 10.4.1.104 -d song_recover song1/song1
Error: Unknown database 'song_recover'
[root@10-4-1-104 ]# ./sys_parser -u sla -p sla -h 10.4.1.104 -d song1_recover song1/song1
CREATE TABLE `song1`(
`id` INT,
WARNING: Fields are not found for table 'song1/song1' in SYS_FIELDS
`name` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci') ENGINE=InnoDB;
[root@10-4-1-104 ]#
轉載請註明源出處
QQ 273002188 歡迎一起學習
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25099483/viewspace-1735927/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 行動硬碟刪除的檔案能恢復嗎,怎樣恢復刪除的檔案硬碟
- 行動硬碟刪除的檔案能恢復嗎,怎麼恢復硬碟刪除的檔案硬碟
- 恢復刪除的檔案
- 刪除檔案的恢復
- Git恢復刪除的檔案Git
- 【Mysql】Mysql從frm檔案裡恢復表結構MySql
- mysql 5.7 刪除ibdata1 、ib_logfile 檔案的資料恢復MySql資料恢復
- 怎樣恢復回收站已刪除檔案,檔案刪除恢復教程
- git恢復誤刪未提交的檔案Git
- mysql 從 frm 檔案恢復 table 表結構的3種方法MySql
- sd卡刪除的檔案如何恢復SD卡
- Shift + Delete刪除的檔案如何恢復?delete
- 使用lsof恢復誤刪除的檔案
- 一個恢復刪除檔案的工具
- eclipse中恢復刪除的檔案Eclipse
- 電腦刪除檔案恢復技巧
- Redo log檔案被刪除恢復
- lsof恢復oracle誤刪除檔案Oracle
- 怎樣恢復已經從回收站刪除的檔案
- 檔案從電腦中徹底刪除怎麼恢復
- 如何使用 testdisk 恢復已刪除的檔案
- Oracle恢復誤刪除的資料檔案Oracle
- linux/uninx恢復刪除的檔案<轉>Linux
- solaris下使用lsof恢復刪除的檔案
- ZT:使用lsof恢復誤刪除的檔案
- 360粉碎檔案可以恢復嗎,如何恢復360強力刪除的檔案
- Oracle 檔案意外刪除恢復(Linux)OracleLinux
- RM 刪除資料檔案恢復操作
- 刪除表空間,有rman全備的恢復(使用dbms_backup_restore來進行恢復)REST
- ibdata1檔案損壞時恢復InnoDB單表測試
- 恢復EXT3下被刪除的檔案
- 被360防毒刪除的檔案怎麼恢復防毒
- 回收站刪除的檔案怎麼恢復?
- 隨身碟被刪除的檔案如何恢復?
- 不小心刪除的檔案怎麼恢復
- Linux下使用lsof恢復刪除的檔案Linux
- Oracle資料恢復 - Linux / Unix 誤刪除的檔案恢復(轉)Oracle資料恢復Linux
- rm -rf 刪除檔案還能恢復嗎?