日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

怎样从frm ibd恢复mysql_怎样从frm,ibd恢复MYSQL

發布時間:2023/12/2 数据库 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 怎样从frm ibd恢复mysql_怎样从frm,ibd恢复MYSQL 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2015-07-01 回答

method #1 – create work tables

1. start up clean/fresh instance of mysql with innodb_file_per_table enabled.

2. now, we need to find the table id that mysql is currently set at, as well as the table id for the table we need to recover.

note:

step 2 (2a – 2f) is simply to find the table id that is stored inside of

the .ibd file. i’ve written a php script to determine this, so using

the script can save a bunch of time. see the bottom of this page (under

“associated files”) for the exact script.

2a. create a test database:

mysql> create database test1;

mysql> use test1;

2b. issue the create table command for the table:

mysql> create table `product` (

`product_id` bigint(20) unsigned not null auto_increment,

`brand_id` int(10) unsigned default null,

`product_type_id` int(10) unsigned default null,

`group_id` int(10) unsigned default null,

`product_name` varchar(500) not null,

`default_email_id` varchar(48) default null,

`product_status` tinyint(1) not null,

`client_id` bigint(20) unsigned default null,

`last_modified_by` varchar(45) not null,

`last_modified_date` datetime not null,

primary key (`product_id`)

) engine=innodb;

2c. discard the tablespace, which will delete the newly created .ibd file:

mysql> alter table product discard tablespace;

2d. copy the pre-existing .ibd file to the datadir/test1 folder

2e. import this tablespace:

mysql> alter table product import tablespace;

this should produce the following error (at least this is most likely).

the only way it would not is if mysql’s current table id matched that of

the preexisting ibd table id. in which case, you can now dump your

table.

error 1030 (hy000): got error -1 from storage engine

2f. so, now to check the error log (manually). look for the following entry:

081010 11:47:40 innodb: error: tablespace id in file

'.test1product.ibd' is 1193, but in the innodb

innodb: data dictionary it is 1.

so, now we know the internal table id is at 1, and that of the ibd table is 1193.

3. clean up working database:

3a. manually move the ibd file from the $datadir to a safe location (as you will need this file again).

3b. drop this table.

mysql> drop table product;

note this does not re-set the internal table counter.

4. you’ll need to create the number of tables you need to increase the internal table id value.

in this case, you’d create 1191 test innodb tables (already at 1, and

need to leave 1 for the actual table, so 1193-2=1191). run below in a

loop.

for ($1=1; $i<=1191; $1++) {

create table t# (id int) engine=innodb;

}

i accomplished this via a simple php script. see the bottom of this page (under "associated files") for the exact script.

5. after these are created, go ahead and drop this database and all tables (as they are not needed).

drop db test1;

6. now, re-perform steps 2a through 2e.

mysql> create database test1;

mysql> use test1;

mysql> create table `product` ( ... ) engine=innodb;

mysql> alter table product discard tablespace;

mysql> alter table product import tablespace;

success!

總結

以上是生活随笔為你收集整理的怎样从frm ibd恢复mysql_怎样从frm,ibd恢复MYSQL的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。