【MySQL】数据迁移之传输表空间

源库
[root@wallet01 ~]# su - mysql
[mysql@wallet01 ~]$ mysqldump -uroot -pabcd.1234 -d tpcc customer >customer.sql
[mysql@wallet01 ~]$ scp customer.sql 192.168.1.202:/home/mysql

[mysql@wallet01 ~]$ mysql -uroot -pabcd.1234
mysql> use tpcc100
Database changed

mysql> select count(*) from customer;
+----------+
| count(*) |
+----------+
|  1500000 |
+----------+
1 row in set (0.33 sec)

目标库
[root@wallet02 ~]# su - mysql
[mysql@wallet02 ~]$ mysql -uroot -pabcd.1234
mysql> create database tpcc;
Query OK, 1 row affected (0.05 sec)

mysql> use tpcc
Database changed

mysql> source customer.sql
Query OK, 0 rows affected (0.01 sec)

mysql>  alter table customer discard tablespace;
Query OK, 0 rows affected (0.03 sec)

源库
mysql> flush table customer for export;
Query OK, 0 rows affected (0.00 sec)

[mysql@wallet01 ~]$ cd /usr/local/mysql/data/tpcc
[mysql@wallet01 tpcc100]$ scp customer.cfg 192.168.1.202:/usr/local/mysql/data/tpcc
[mysql@wallet01 tpcc100]$ scp customer.ibd 192.168.1.202:/usr/local/mysql/data/tpcc

mysql>  unlock tables;
Query OK, 0 rows affected (0.03 sec)

目标库
mysql> alter table customer import tablespace; 
Query OK, 0 rows affected (11.52 sec)

mysql> select count(*) from customer;
+----------+
| count(*) |
+----------+
|  1500000 |
+----------+
1 row in set (0.37 sec)

猜你喜欢

转载自blog.51cto.com/13598811/2384914