| title | Migration Overview | |
|---|---|---|
| summary | Learn how to migrate data into TiDB. | |
| category | how-to | |
| aliases |
|
This document describes scenarios for migrating data into TiDB from either MySQL or another data source via CSV format.
Migrations will often make use of the following tools. The following is a brief overview of their usage:
mydumperexports data from MySQL. It is recommended over using mysqldump.loaderimports data in mydumper format into TiDB.synceracts like a MySQL replication slave and pushes data from MySQL into TiDB.- DM (Data Migration) integrates the functions of mydumper, Loader and syncer to support the export and import of full-size data, as well as incremental replication of MySQL Binlog data, and supports data replication of a more complete pooled table scenario.
- TiDB-Lightning imports data to TiDB in an optimized way. For example, a 1TiB backup could take 24+ hours to import with loader, while it will typically complete at least 3 times faster in TiDB-Lightning.
The following example scenarios show how you can put to use the tools mentioned above.
To migrate the full data, you can use one of the following three solutions:
- mydumper + Loader: use mydumper to export data from MySQL and use Loader to import the data into TiDB.
- mydumper + TiDB-Lightning: use mydumper to export data from MySQL and use TiDB-Lightning to import the data into TiDB.
- DM: use DM to export data from MySQL and import the data into TiDB.
For detailed operations, follow the steps in Migrate Data from MySQL to TiDB.
To migrate the full data and then replicate data incrementally, you can use one of the following three solutions:
- mydumper + Loader + Syncer: use mydumper to export data from MySQL, use Loader to import the data into TiDB, and then use Syncer to replicate the incremental binlog data from MySQL into TiDB.
- mydumper + TiDB-Lightning + Syncer: use mydumper to export data from MySQL, use TiDB-Lightning to import the data into TiDB, and then use Syncer to replicate the incremental binlog data from MySQL into TiDB.
- DM: use DM to migrate the full data from MySQL to TiDB and then replicate the incremental data from MySQL into TiDB.
For detailed operations, follow the steps in Incremental Migration.
Note:
To replicate data from MySQL to TiDB, binary logging must be enabled with the row format enabled.
To import data from another database, it is recommended to:
- Export the data as CSV format.
- Import the data using TiDB-Lightning.
For more information, refer to CSV support for TiDB-Lightning.