MySQL 5.6.26 Data recovery process with frm & IBD

Source: Internet
Author: User
Tags file permissions

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.