content_image/748045.jpg content_image/748046.jpg content_image/748047.jpg content_image/748048.jpg
mysql> \! ls /path/to/datadir /test/ t1#p#p0.ibd t1#p#p1.ibd t1#p#p2.ibd t1#p#p3.ibd 

2. On the destination instance, discard the partitions that you intend to import from the source instance. (Before importing partitions, you must discard the corresponding partitions from the receiving partitioned table.) 

mysql> ALTER TABLE t1 DISCARD PARTITION p2, p3 TABLESPACE; 

The tablespace .ibd  files for the two discarded partitions are removed from the / datadir /test directory on the destination instance, leaving the following files: 

mysql> \! ls /path/to/datadir /test/ t1#p#p0.ibd t1#p#p1.ibd 

<img src='content_image/748045.jpg'>

<img src='content_image/748046.jpg'>

## Note 

When ALTER TABLE ... DISCARD PARTITION ... TABLESPACE  is run on subpartitioned tables, both partition and subpartition table names are permitted. When a partition name is specified, subpartitions of that partition are included in the operation. 

3. On the source instance, run FLUSH TABLES ... FOR EXPORT  to quiesce the partitioned table. When a table is quiesced, only read-only transactions are permitted on the table. 

mysql> USE test; mysql> FLUSH TABLES t1 FOR EXPORT; 

FLUSH TABLES ... FOR EXPORT  ensures that changes to the named table are flushed to disk so that binary table copy can be made while the instance is running. When FLUSH TABLES ... FOR EXPORT  is run, InnoDB  generates a .cfg  metadata file for each of the table’s tablespace files in the schema directory of the table. 

mysql> \! ls /path/to/datadir /test/ t1#p#p0.ibd t1#p#p1.ibd t1#p#p2.ibd t1#p#p3.ibd t1#p#p0.cfg t1#p#p1.cfg t1#p#p2.cfg t1#p#p3.cfg 

The .cfg  files contain metadata that used for schema verification during the import operation. FLUSH TABLES ... FOR EXPORT  can only be run on the table, not on individual table partitions. 

4. Copy the .ibd  and .cfg  files for partition p2  and partition p3  from the source instance schema directory to the destination instance schema directory. 

shell> scp t1#p#p2.ibd t1#p#p2.cfg t1#p#p3.ibd t1#p#p3.cfg destination-server: /path/to/datadir /test 

The .ibd  and .cfg  files must be copied before releasing the shared locks, as described in the next step. 

<img src='content_image/748047.jpg'>

<img src='content_image/748048.jpg'>

## Note 

If you are importing partitions from an encrypted tablespace, InnoDB  generates a .cfp  files in addition to a .cfg  metadata files. The .cfp  files must be copied to the destination instance together with the .cfg  files. The .cfp  files contain a transfer key and an encrypted tablespace key. On import, InnoDB  uses the transfer key to decrypt the tablespace key. For related information, see Section 15.13, “InnoDB Data-at-Rest Encryption” . 

