简体   繁体   中英

How to export all innodb tables?

I am using this command to export all database.

mysqldump -u root -p --all-databases > alldb.sql

But it export all tables including MyISAM, However I want to only export and import innodb tables of all databases.

You have to be careful exporting and importing data from InnoDB tables. InnoDB tables "might" contain foreign keys (child and parent table). If the script executed the child table first, then there's a possibility MySQL might produce an error because the Parent table has not exist yet. You can do well MyISAM since they are not strict, doesn't care about foreign keys.

You can follow the below steps

use mysql;
show table status name where engine='innodb';

and do a rectangular copy/paste from the Name column:

+-----------+--------+---------+------------+-
| Name      | Engine | Version | Row_format |
+-----------+--------+---------+------------+-
| db1       | InnoDB |      10 | Compact    |
| db2       | InnoDB |      10 | Compact    |
| db3       | InnoDB |      10 | Compact    |  |
+-----------+--------+---------+------------+-

to a text editor and convert it to a command

mysqldump -u username --databases db1 db2 db3 > DUMP.sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM