All Products
Search
Document Center

:Migrate from RDS for MySQL to self-managed MySQL

Last Updated:Jun 24, 2026

You can use Data Transmission Service (DTS) to migrate data from an ApsaraDB RDS for MySQL instance to a self-managed MySQL database. This is useful for use cases such as data analytics and business feature testing.

Prerequisites

  • Tables that you migrate from the ApsaraDB RDS for MySQL instance must have a primary key or a unique non-null index.

  • The storage space of the self-managed MySQL database must be larger than that used by the ApsaraDB RDS for MySQL instance.

  • To ensure compatibility, the version of the self-managed MySQL database must match that of the ApsaraDB RDS for MySQL instance.

Usage notes

  • During a full data migration, DTS consumes read and write resources on the source and destination databases, increasing their load. If your databases have poor performance, low specifications, or high workloads (for example, if the source database has many slow SQL queries or tables without primary keys, or if deadlocks occur in the destination database), the increased load can strain your databases or even cause service interruptions. Perform the data migration during off-peak hours, such as when the CPU utilization of both databases is below 30%.

  • If a source table lacks a primary key, unique constraint, or any field combination that ensures uniqueness, DTS may generate duplicate data in the destination.
  • Full data migration uses concurrent INSERT operations that cause table fragmentation. The destination tablespace will be larger than the source after migration.
  • DTS automatically recovers failed tasks. Before switching workloads to the destination, stop or release the migration task to prevent it from resuming and overwriting destination data.
  • You cannot adjust the rate of a full data migration.

Limitations

  • DTS supports schema migration for tables, views, triggers, stored procedures, and stored functions.
    Note During schema migration, DTS changes the DEFINER for views, stored procedures, or functions to INVOKER.
  • DTS does not migrate user information. To call views, stored procedures, or functions in the destination, grant read and write permissions to the caller.

Migration types

DTS supports schema migration, full data migration, and incremental data migration. For more information, see Key concepts.

Note

By using all three migration types together, you can achieve a smooth, zero-downtime database migration.

Billing

Migration type

Task configuration fee

Internet traffic fee

Schema migration and full data migration

Free of charge.

Fees apply only when data is migrated over the internet from Alibaba Cloud. For more information, see Billing overview.

Incremental data migration

Charged. For more information, see Billing overview.

SQL operations for incremental migration

Operation type

SQL statement

DML

INSERT, UPDATE, DELETE, and REPLACE

DDL

  • ALTER TABLE and ALTER VIEW

  • CREATE FUNCTION, CREATE INDEX, CREATE PROCEDURE, CREATE TABLE, and CREATE VIEW

  • DROP INDEX and DROP TABLE

  • RENAME TABLE

  • TRUNCATE TABLE

Required privileges for database accounts

Database

Required privileges

ApsaraDB RDS for MySQL

Read privileges on the migration objects.

Self-managed MySQL database

Read and write privileges on the migration objects.

To create a database account and grant privileges:

Procedure

  1. Log on to the DTS console.

    Note

    If you are automatically redirected to the Data Management (DMS) console, you can click the jiqiren icon in the lower-right corner and then click 返回旧版 to return to the classic DTS console.

  2. In the left-side navigation pane, click Data Migration.

  3. At the top of the Migration Tasks page, select the region of the destination cluster.

  4. In the upper-right corner of the page, click Create Data Migration Task.

  5. Configure the connection settings for the source and target databases.

    Category

    Parameter

    Description

    N/A

    Task name

    DTS automatically generates a task name. Specify a descriptive name for easy identification. The name does not need to be unique.

    Source Database

    Instance type

    Select RDS.

    Instance region

    Select the region where the source RDS instance is located.

    RDS instance ID

    Select the ID of the source RDS instance.

    Database account

    Enter the account of the ApsaraDB RDS for MySQL database. For information about the required privileges, see Required privileges for database accounts.

    Password

    Enter the password for the database account.

    Note

    After you enter the source database information, you can click Test Connectivity next to Database Password to verify that the entered information is correct. If the information is correct, a Passed message is displayed. If a Failed message is displayed, click Diagnose next to Failed and adjust the source database information based on the prompts.

    Connection method

    Select Non-encrypted or SSL-encrypted based on your requirements. If you select SSL-encrypted, you must first enable SSL encryption for the source RDS instance. For more information, see Configure SSL encryption.

    Note

    Currently, the Encryption parameter is available only in the Chinese mainland and China (Hong Kong) regions.

    Target Database

    Instance type

    Select a type based on where your database is deployed. This topic uses Self-managed database on an ECS instance as an example.

    Note

    When your self-managed database is of another instance type, you must perform additional preparations. For more information, see Preparations overview.

    Instance region

    Select the region where the ECS instance is located.

    ECS instance ID

    Select the ID of the ECS instance that hosts the self-managed MySQL database.

    Database type

    Select MySQL.

    Port

    Enter the port number of the database service. In this example, enter 3306.

    Database account

    Enter the account of the self-managed MySQL database. For information about the required privileges, see Required privileges for database accounts.

    Password

    Enter the password for the database account.

    Note

    After you enter the target database information, you can click Test Connectivity next to Database Password to verify that the information you entered is correct. If the information is correct, a Passed message is displayed. If a Failed message is displayed, click Diagnose next to the Failed message and adjust the target database information based on the prompts.

    Connection method

    Select Non-encrypted or SSL-encrypted based on your requirements. In this example, Non-encrypted is selected.

  6. After you complete the configurations, click Set Allowlist and Continue in the lower-right corner of the page.

    If the source or target database is an Alibaba Cloud database instance, such as ApsaraDB RDS for MySQL or ApsaraDB for MongoDB, DTS automatically adds the IP addresses of DTS servers in the corresponding region to the allowlist of the instance. If the source or target database is a self-managed database on an ECS instance, DTS automatically adds the IP addresses to the security group rules of the ECS instance. You must also ensure that the self-managed database allows access from the ECS instance. If the database is deployed as a cluster on multiple ECS instances, you must manually add the IP addresses of the DTS servers to the security group rules for each ECS instance. If the source or target database is a self-managed database in a data center or a database from another cloud provider, you must manually add the IP addresses of DTS servers in the corresponding region to allow access. For a list of the IP addresses of DTS servers, see IP addresses of DTS servers.

    Warning

    Adding the public CIDR blocks of DTS servers, whether automatically or manually, may introduce security risks. By using this product, you acknowledge and accept these potential risks. You are responsible for implementing basic security measures, including but not limited to using strong passwords, restricting open ports, using authentication for internal API calls, regularly reviewing and restricting unnecessary network segments, or connecting through private networks such as Express Connect, VPN Gateway, or Smart Access Gateway.

  7. Select the migration types and the objects to be migrated.

    Parameter

    Description

    Migration types

    • To perform only a full migration, select both Schema Migration and full data migration.

    • To perform a migration with minimal downtime, select Schema Migration, full data migration, and incremental data migration.

    Note

    If you do not select incremental data migration, do not write new data to the source database during migration to ensure data consistency.

    Migration objects

    In the Available box, click the objects that you want to migrate, and then click the 向右小箭头 icon to move them to the Selected Objects box.

    Note
    • You can select databases, tables, and columns as migration objects.

    • By default, object names in the destination database are the same as in the source database. To rename an object in the destination database, use the object name mapping feature. For more information, see Object name mapping.

    • If you use the object name mapping feature, dependent objects might fail to migrate.

    Mapped name change

    To rename migration objects in the destination instance, use the object name mapping feature. For more information, see Object name mapping.

    Retry time for failed connection to source or destination database

    By default, if DTS cannot connect to the source or destination database, it retries for 720 minutes (12 hours). You can customize the retry time. If DTS reconnects within the specified time, the migration task automatically resumes. Otherwise, the migration task fails.

    Note

    You are charged for the task while DTS retries the connection. We recommend that you set the retry time based on your business needs or release the DTS instance as soon as possible after the source and destination database instances are released.

    Replicate temporary table to destination during online DDL in source table by DMS

    If you use Data Management (DMS) to perform online DDL operations on the source database, choose whether to migrate the temporary tables generated by these operations.

    • Yes: Migrate the data from the temporary tables generated by online DDL operations.

      Note

      If the temporary tables generated by online DDL operations contain a large amount of data, the migration task may be delayed.

    • No: Do not migrate data from temporary tables. Only the original DDL data from the source database is migrated.

      Note

      This option may cause tables in the destination database to be locked.

  8. After you complete the configuration, click Precheck and Start in the lower-right corner of the page.

    Note
    • Before the migration task starts, DTS runs a precheck. The task can start only after it passes the precheck.

    • If the precheck fails, click the 提示 icon next to the failed item to view details.

      • Fix the issues as prompted and run the precheck again.

      • If you do not need to fix the warning items, you can select Ignore and then click Ignore Warnings and Rerun Precheck to run the precheck again.

  9. After the task passes the precheck, click Next.

  10. In the Confirm Settings dialog box that appears, select a Instance Class and select the Data Transmission Service (pay-as-you-go) Service Terms checkbox.

  11. Click Buy and Start to begin the migration.

    • Schema migration + Full data migration

      Allow the task to complete automatically. Stopping it manually may result in incomplete data.

    • Schema migration + Full data migration + Incremental data migration

      The migration task does not stop automatically. You must stop it manually.

      Important

      Choose an appropriate time to stop the task manually, such as during off-peak hours or when you are ready to switch your business to the destination cluster.

      1. Wait until the migration task enters the Incremental Data Migration phase and the status shows Undelayed. Then, stop writing data to the source database for several minutes. During this time, the status of Incremental Data Migration may show a latency.

      2. Wait for the Incremental Data Migration status to show Undelayed again. Then, manually stop the migration task.结束增量迁移任务