>show variables like '%per_table%'; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | innodb_file_per_table | ON | +-----------------------+-------+ 1 row in set (0.00 sec)
-rw-rw---- 1 mysql mysql 8602 Feb 13 23:10 users.frm -rw-rw---- 1 mysql mysql 11534336 Mar 12 22:55 users.ibd数据情况:
> select count(*) from users; +----------+ | count(*) | +----------+ | 20001 | +----------+ 1 row in set (0.01 sec)我们开始迁移数据,首先要生成一个cfg文件,导出配置信息。
-rw-rw---- 1 mysql mysql 599 Mar 13 08:17 users.cfg -rw-rw---- 1 mysql mysql 8602 Feb 13 23:10 users.frm -rw-rw---- 1 mysql mysql 11534336 Mar 12 22:55 users.ibd在flush table之后,这个表users就被锁定了,DML操作是阻塞的,也就意味着迁移的过程中,是无法直接写入数据的。
> alter table users import tablespace; ERROR 1808 (HY000): Schema mismatch (Table flags don't match, server table has 0x5 and the meta-data file has 0x1)或者下面的错误:
> alter table users import tablespace; ERROR 1808 (HY000): Schema mismatch (Table has ROW_TYPE_DYNAMIC row format, .ibd file has ROW_TYPE_COMPACT row format.)通过错误信息可以发现和表的一个属性有关。我们先解决问题,添加属性row_format