Use Data Transmission Service (DTS) to continuously synchronize data from a self-managed MySQL database on Elastic Compute Service (ECS) to a PolarDB for MySQL cluster — including both historical data and ongoing changes.
Prerequisites
Before you begin, ensure that you have:
A PolarDB for MySQL cluster. To create one, see Purchase a pay-as-you-go cluster.
A database account on the self-managed MySQL database with the required permissions. See Create an account for a self-managed MySQL database and configure binary logging.
Source database account permissions
The database account must have the following permissions on the objects to be synchronized:
SELECT on objects to be synchronized
REPLICATION CLIENT
REPLICATION SLAVE
SHOW VIEW
Destination cluster account permissions
The database account on the PolarDB for MySQL cluster must have read and write permissions on all objects to be synchronized.
Billing
| Synchronization type | Fee |
|---|---|
| Schema synchronization and full data synchronization | Free of charge |
| Incremental data synchronization | Charged. See Billing overview. |
Supported SQL operations
| Type | Operations |
|---|---|
| DML | INSERT, UPDATE, DELETE, REPLACE |
| DDL | ALTER TABLE, ALTER VIEW, CREATE FUNCTION, CREATE INDEX, CREATE PROCEDURE, CREATE TABLE, CREATE VIEW, DROP INDEX, DROP TABLE, RENAME TABLE, TRUNCATE TABLE |
RENAME TABLE operations can cause data inconsistency. If you select a specific table as the synchronization object and rename it during synchronization, changes to that table stop being replicated to the destination cluster. To prevent this, select the parent database (not the individual table) as the synchronization object, and make sure the database is included in the synchronization objects both before and after the rename.
Supported synchronization topologies
One-way one-to-one synchronization
One-way one-to-many synchronization
One-way cascade synchronization
One-way many-to-one synchronization
For details, see Synchronization topologies.
Limitations
Trigger incompatibility
If you select a database as the object to synchronize and the database contains a trigger that updates a table, data inconsistency may occur. See Configure a data synchronization task for a source database that contains a trigger for a workaround.
Primary key requirement
Source tables must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Without this, the destination cluster may contain duplicate records.
Usage notes
DTS reads from the source and writes to the destination during initial full data synchronization, increasing the load on both instances. Run the synchronization task during off-peak hours, when CPU utilization on both instances is below 30%.
Do not use gh-ost or pt-online-schema-change for DDL operations during synchronization. These tools can cause the task to fail.
Concurrent INSERT operations during initial full data synchronization create table fragmentation in the destination cluster. After synchronization completes, the destination tablespace will be larger than the source.
Adding DTS server CIDR blocks to your whitelist or security group rules introduces security risks. Take preventive measures such as restricting exposed ports, auditing whitelist entries regularly, and considering private connectivity options like Express Connect, VPN Gateway, or Smart Access Gateway (SAG) instead of public internet access.
Set up the synchronization task
Step 1: Purchase a DTS instance
Purchase a DTS instance. On the purchase page, set:
Source Instance: MySQL
Destination Instance: PolarDB
Synchronization Topology: One-way Synchronization
Step 2: Configure source and destination databases
Log on to the DTS console.
If you are redirected to the Data Management (DMS) console, click the
icon in the
to return to the previous version of the DTS console.In the left-side navigation pane, click Data Synchronization.
At the top of the Synchronization Tasks page, select the region where the destination instance resides.
Find the synchronization instance and click Configure Task in the Actions column.
Configure the source and destination databases using the following parameters.
Source database
Parameter Description Task Name A descriptive name for the task. Does not need to be unique. Instance Type Select User-Created Database in ECS Instance. Instance Region The source region you selected on the purchase page. Read-only. ECS Instance ID The ID of the ECS instance that hosts the self-managed MySQL database. Database Type Set to MySQL. Read-only. Port Number The port number of the self-managed MySQL database. Database Account The account with the required permissions listed in the Prerequisites. Database Password The password for the database account. Destination database
Parameter Description Instance Type Set to PolarDB Instance. Read-only. Instance Region The destination region you selected on the purchase page. Read-only. PolarDB Instance ID The ID of the destination PolarDB for MySQL cluster. Database Account The account with read and write permissions on the objects to be synchronized. Database Password The password for the database account.
Step 3: Configure the whitelist
Click Set Whitelist and Next in the lower-right corner.
If the source or destination database is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers to the IP address whitelist of the instance.
If the source or destination database is a self-managed database hosted on an ECS instance, DTS automatically adds the CIDR blocks of DTS servers to the security group rules of the ECS instance. If the database is hosted across multiple ECS instances, manually add the DTS CIDR blocks to the security group rules of each instance.
If the source or destination database is a self-managed database deployed in a data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers to the IP address whitelist of the database.
For more information, see Add the CIDR blocks of DTS servers.
Step 4: Select objects and configure conflict handling
Configure the following settings, then click Next.
| Setting | Description |
|---|---|
| Processing mode for existing target tables | Pre-check and Intercept (default): DTS checks whether the destination cluster has tables with the same names as the source. The task fails precheck if conflicts are found. Use the object name mapping feature to resolve naming conflicts without deleting destination tables.<br><br>Ignore: Skips the name conflict check. During initial synchronization, DTS skips records that share primary keys with existing destination records. During incremental synchronization, DTS does write those records. If schemas differ between source and destination, the task may fail or synchronize only partial data. |
| Objects to synchronize | Select tables or databases from the Available section and click |
| Rename databases and tables | Use object name mapping to rename objects in the destination cluster. |
| Source table DMS_ ONLINE_ Do you want to copy the temporary table to the target database during DDL | If you use Data Management (DMS) to run online DDL operations on the source database, choose whether to synchronize the temporary tables generated by those operations.<br><br>Yes: Synchronizes temporary table data. Large online DDL operations may increase synchronization latency.<br><br>No: Skips temporary tables and synchronizes only the original DDL. Destination tables may be temporarily locked. |
| Retry time for failed connections | Default is 720 minutes (12 hours). If DTS reconnects within this window, the task resumes automatically. If the retry window expires without reconnection, the task fails. DTS charges apply while retries are in progress. |
Selecting Ignore does not guarantee data consistency. During initial synchronization, DTS skips records whose primary keys already exist in the destination. During incremental synchronization, DTS writes those same records. If source and destination schemas differ, the task may fail or produce incomplete data.
Step 5: Select initial synchronization types
Select the synchronization types to include.

Selecting both Initial Schema Synchronization and Initial Full Data Synchronization causes DTS to replicate existing schemas and data before switching to incremental synchronization.
Step 6: Run the precheck and start synchronization
Click Precheck in the lower-right corner.
If the precheck fails, click the
icon next to each failed item to view details. Fix the issues and run the precheck again. If you do not need to fix an issue, ignore the failed item and start a new precheck.After the Precheck Passed message appears, close the Precheck dialog box. The synchronization task starts automatically.
On the Synchronization Tasks page, monitor the task status. Wait until initial synchronization is complete and the task enters the Synchronizing state.

What's next
To rename objects during synchronization, see Rename an object to be synchronized.
To learn about all supported synchronization topologies, see Synchronization topologies.