mysql database:傳輸表空間
阿新 • • 發佈:2018-11-22
源庫 [[email protected] ~]# su - mysql [[email protected] ~]$ mysql -utpcc -ptpcc mysql> use tpcc1000 Database changed mysql> select count(*) from history; +----------+ | count(*) | +----------+ | 3761403 | +----------+ 1 row in set (1.16 sec) mysql> show create table history; +--------- +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------- +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | history | CREATE TABLE `history` ( `h_c_id` int(11) DEFAULT NULL, `h_c_d_id` tinyint(4) DEFAULT NULL, `h_c_w_id` smallint(6) DEFAULT NULL, `h_d_id` tinyint(4) DEFAULT NULL, `h_w_id` smallint(6) DEFAULT NULL, `h_date` datetime DEFAULT NULL, `h_amount` decimal(6,2) DEFAULT NULL, `h_data` varchar(24) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | +--------- +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------+ 目標庫 [[email protected] ~]# su - mysql [[email protected] ~]$ mysql -utpcc -ptpcc mysql> use tpcc1000 Database changed mysql> create table `history` ( -> `h_c_id` int(11) DEFAULT NULL, -> `h_c_d_id` tinyint(4) DEFAULT NULL, -> `h_c_w_id` smallint(6) DEFAULT NULL, -> `h_d_id` tinyint(4) DEFAULT NULL, -> `h_w_id` smallint(6) DEFAULT NULL, -> `h_date` datetime DEFAULT NULL, -> `h_amount` decimal(6,2) DEFAULT NULL, -> `h_data` varchar(24) DEFAULT NULL -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8; mysql> alter table history discard tablespace; Query OK, 0 rows affected (0.23 sec) 源庫 mysql> flush table history for export; Query OK, 0 rows affected (0.08 sec) [[email protected] ~]$ cd /usr/local/mysql/data/tpcc1000/ [[email protected] tpcc1000]$ scp history.cfg [email protected]:/usr/local/mysql/data/tpcc1000/ [[email protected] tpcc1000]$ scp history.ibd [email protected]:/usr/local/mysql/data/tpcc1000/ mysql> unlock tables; Query OK, 0 rows affected (0.00 sec) 目標庫 mysql> alter table history import tablespace; Query OK, 0 rows affected (8.60 sec) mysql> select count(*) from history; +----------+ | count(*) | +----------+ | 3761403 | +----------+ 1 row in set (2.27 sec)