MySQL InnoDB引擎的表通过拷贝物理文件来进行单表或指定表的复制,可以想到多种方式,今天测试其中2种:
将innodb引擎的表修改为Myisam引擎,然后拷贝物理文件
直接拷贝innodb的表空间文件(前提是独立表空间(默认,通过show variables like 'innodb_file_per_table' 查看))进行复制
一、修改引擎
1.创建一张innodb引擎的表,并插入测试数据;
create table test_tb(id int primary key,c1 varchar(20)) ENGINE=InnoDB DEFAULT CHARSET=utf8;insert into test_tb select 1,'c1';insert into test_tb select 2,'c2';
2. 修改引擎
alter table test_tb engine=myisam;
showcreate table test_tb\G
3. 将物理文件拷贝至目标库
cd /data/mysql/my