tencent cloud

Migrate Small Dataset from TiDB
Last updated:2026-02-10 11:06:01
Migrate Small Dataset from TiDB
Last updated: 2026-02-10 11:06:01
Dumpling is a tool that exports TiDB data into SQL or CSV files. This document describes how to use Dumpling to export full data from a self-hosted TiDB cluster.

Prerequisites

1. Prepare the deployment environment.
It is recommended to deploy Dumpling on servers that have network connectivity with the source MySQL/TiDB and target TDSQL Boundless instances awaiting migration.
2. Deploy Dumpling with TiUP
## Deploy TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source /root/.bash_profile

## Deploy Dumpling and upgrade to the latest version
tiup install dumpling
tiup update --self && tiup update dumpling
3. Configure the required permissions for Dumpling
You require the following permissions to export data from the upstream database:
SELECT
RELOAD
LOCK TABLES
REPLICATION CLIENT
PROCESS

Steps

The following example demonstrates how to use Dumpling to export SQL files from TiDB, import them into TDSQL Boundless using the community tool myloader, and enable TiCDC for incremental synchronization.
1. Disable the GC temporarily for the upstream TiDB cluster.
To ensure that newly written data is not lost during incremental migration, you should disable the garbage collection (GC) for the upstream cluster before the migration is started. In this way, history data is not deleted.
Run the following command to disable GC:
SET GLOBAL tidb_gc_enable = FALSE;
To verify that the change takes effect, query the value of tidb_gc_enable:
SELECT @@global.tidb_gc_enable;
The following is an example output, where 0 indicates disabled.
+-------------------------+
| @@global.tidb_gc_enable |
+-------------------------+
| 0 |
+-------------------------+
1 row in set (0.00 sec)
2. Run Dumpling to export the full data as SQL files.
tiup dumpling -u root -P 4000 -h tidb_host -o /tmp/test
Dumpling exports data in SQL format by default. For partial data export or filtering, refer to the Dumpling usage instructions.
3. Check the exported data.
Typically, exported data includes the following:
metadata: contains the export start time and the binlog position of the master database
{schema}-schema-create.sql: SQL file for creating schema
{schema}.{table}-schema.sql: SQL file for creating tables
{schema}.{table}.{0001}.{sql|csv}: data file
*-schema-view.sql, *-schema-trigger.sql, *-schema-post.sql: other exported SQL files
Take the following metadata file as an example:
Started dump at: 2025-12-02 12:42:53
SHOW MASTER STATUS:
Log: tidb-binlog
Pos: 462583122654920710
GTID:

Finished dump at: 2025-12-02 12:42:53
Where Pos is followed by a number representing the TiDB timestamp used for export. This timestamp will be used as the starting point for TiCDC replay in subsequent incremental migration settings.
4. Import Data
Use the myloader tool to import data. In the following example, the directory used in -d is the directory exported by Dumpling in the previous example.
myloader -h tdsql_host -P 3306 --user tdsqluser -d /tmp/test
5. Performing incremental synchronization via TiCDC. In the following example, set start-ts to the timestamp obtained from the Dumpling metadata. For details, refer to the TiDB official documentation.
tiup cdc cli changefeed create --server=http://ticdc_host:8300 --sink-uri='mysql://tdsql_user@tdsql_host:3306' --changefeed-id="upstream-to-downstream" --start-ts="462583122654920710"
6. To resume GC of TiDB, run the following command:
SET GLOBAL tidb_gc_enable = TRUE;
To verify that the change takes effect, query the value of tidb_gc_enable:
SELECT @@global.tidb_gc_enable;
The expected output is 1, indicating that it is enabled:
+-------------------------+
| @@global.tidb_gc_enable |
+-------------------------+
| 1 |
+-------------------------+
1 row in set (0.00 sec)
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback