. Frm and Ibd can be used to restore InnoDB tables in batches.
Create a table structure that has been lost
You need to install mysql-utilities first.
// RedHatyum -y install MySQL-servermysql-utilities//debianapt install MySQL-utilities.
Use mysqlfrm to derive from. Frm file.
//Analyze a. frm file to generate a table-building statement MySQL frm-diagnostic/var/lib/MySQL/test/t1. Frm// all analysis. A table-building statement root @ username: ~ # mysqlfrm-diagnostic/var/lib/MySQL/my _ createtb.sqlroot @ username: ~ # grep "create table" createtb.sql |wc -l 124.
As you can see, a * * * generated 124 table construction statements.
Many times, table construction statements can be generated from other libraries, just like other databases of an application or different test environments. The following mysqldump is used to generate table construction statements:
mysqldump-no-data-compact my _ db & gt; createtb.sql
Log in to MySQL to generate tables.
Mysql & gt create database my _ dbmysql & gt use my _ dbdatabaseChangedMySQL & gt sourcecreatetb.sqlquery is normal, and line 0 is affected (0.07 seconds). ......
Import old data files
Discard the newly created. Ibd file without data.
root @ username:/var/lib/MySQL/my _ db # ll *IBD | WC 124 1 1 16794 1 root @ username:/var/lib/MySQL/my _ db # MySQL-e " show tables from my _ db " \ | grep-v? Tables in my database? \ | When reading a; do mysql -e "ALTER TABLE my_db。 $a Discard tablespaces "; done root @ username:/var/lib/MySQL/my _ db # ll *。 Ibd|wcls: Cannot access' *'. Ibd': There is no such file or directory 000.
You can see all of them. Idb file has been discarded. Then copy the old one. Ibd file, and don't forget to change the owner: chown mysql. *, and then import these data files into the database.
root @ username:/var/lib/MySQL/my _ db # MySQL-e " show tables from my _ db " \ | grep-v? Tables in my database? \ | When reading a; \do mysql -e "modify table my_db. $a Import Tablespace "; finished
List after the import is completed.
Use mysqlcheck to check all tables under the database my_db:
root @ username:/var/lib/MySQL/my _ db # MySQL check-c my _ dbmy _ db . CDP _ backup _ point OK ......
All tables have been successfully imported.