Create a database on a server Yoon
Root (Yoon) > Show CREATE TABLE Yoon\g
1. Row ***************************
Table:yoon
Create table:create Table ' Yoon ' (
' id ' int (one) DEFAULT NULL,
' Name ' varchar (DEFAULT NULL)
) Engine=innodb DEFAULT Charset=utf8
Inserting data
Root (Yoon) > INSERT into Yoon values (1, ' HANK ');
Query OK, 1 row affected (1.01 sec)
Root (Yoon) > INSERT INTO Yoon values (2, ' Yoon ');
Query OK, 1 row affected (0.04 sec)
Root (Yoon) > INSERT into Yoon values (3, ' GARY ');
Query OK, 1 row Affected (0.00 sec)
Root (Yoon) > INSERT INTO Yoon Values (4, ' NIKO ');
Query OK, 1 row affected (0.02 sec)
Root (Yoon) > select * from Yoon;
+------+------+
| ID | name |
+------+------+
| 1 | HANK |
| 2 | YOON |
| 3 | GARY |
| 4 | NIKO |
+------+------+
4 rows in Set (0.00 sec)
On the B server, add the parameter Innodb_force_recovery=1 and restart, create the empty database Yoon, and create the table Yoon
mysql> CREATE Database Yoon;
Use Yooquery OK, 1 row affected (1.01 sec)
Mysql> Use Yoon;
Database changed
mysql> CREATE TABLE ' Yoon ' (
' id ' int (one) DEFAULT NULL,
' Name ' varchar (DEFAULT NULL)
) Engine=innodb DEFAULT Charset=utf8;
Query OK, 0 rows affected (0.09 sec)
Detach the table structure and space
Mysql> ALTER TABLE Yoon Discard tablespace;
Query OK, 0 rows affected (0.02 sec)
To transfer the IBD data file on Server A to the B server
SCP YOON.IBD 182.19.4.7:/export/data/mysql/data/yoon
Modify Permissions
Chown-r Mysql.mysql YOON.IBD
Building relationships between table structure and space
Mysql> ALTER TABLE Yoon Import tablespace;
Query OK, 0 rows affected, 1 warning (0.04 sec)
Querying data
Mysql> select * from Yoon;
+------+------+
| ID | name |
+------+------+
| 1 | HANK |
| 2 | YOON |
| 3 | GARY |
| 4 | NIKO |
+------+------+
4 rows in Set (0.00 sec)
The detailed steps are as follows:
1. Stop MySQL service, add innodb_force_recovery=1, start MySQL service
2. Create a new database and create a table with the same table structure (the table structure must be the same)
3, execute ALTER TABLE TB discard tablespace;
4. Remove the IBD file from the table
5. Cross-server replication table IBD files
6, modify the IBD file permissions, execute ALTER TABLE TB import tablespace;
MySQL 5.6.26 Data recovery process with frm & IBD