DTS cannot be used to migrate data of RDS MariaDB instances. You can use mysqldump to migrate data between RDS MariaDB instances. This topic describes the migration procedure.

Background information

The MariaDB 10.3 version is used as an example.

Prerequisites

  • You have installed Linux 7 and MySQL 5.7 on a local host or an Alibaba Cloud ECS instance.
  • You have configured a whitelist for both of the RDS MariaDB instances and allowed the public IP address of the host or ECS instance running Linux 7 to access the instances. For more information about how to configure a whitelist, see Configure a whitelist for an RDS MariaDB instance.
  • You have applied for public IP addresses for both of the RDS MariaDB instances. For more information, see Apply for a public endpoint for an RDS for MariaDB instance.

Procedure

  1. Use a client tool to log on to the destination RDS MariaDB instance and create a database.
  2. Log on to the host or ECS instance running Linux 7, and use the mysqldump tool to export the data of the source RDS MariaDB instance as a data file.
    mysqldump -h <Public IP address of the source instance> -P <Port of the source instance> -u <Privileged account of the source instance> -p<Privileged account password of the source instance> --opt --default-character-set=utf8 --hex-blob <Name of the database to be migrated> --skip-triggers > /tmp/<Name of the database to be migrated>.sql

    Example:

    mysqldump -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test -pTestxxx --opt --default-character-set=utf8 --hex-blob testdb --skip-triggers > /tmp/testdb.sql
    Note Do not update data during the export process. This step only exports data. It does not export stored procedures, triggers, or functions.
  3. Use mysqldump to export stored procedures, triggers, and functions.
    mysqldump -h <Public IP address of the source instance> -P <Port of the source instance> -u <Privileged account of the source instance> -p<Privileged account password of the source instance> --opt --default-character-set=utf8 --hex-blob <Name of the database to be migrated> -R > /tmp/<Name of the database to be migrated>trigger.sql

    Example:

    mysqldump -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test -pTestxxx --opt --default-character-set=utf8 --hex-blob testdb -R > /tmp/testdbtrigger.sql
    Note Skip this step if no stored procedures, triggers, or functions are used in the database.
  4. Run the following statements to import data files, stored procedures, triggers, and functions to the destination RDS MariaDB instance:
    mysql -h <Public IP address of the destination instance> -P <Port of the destination instance> -u <Privileged account of the destination instance> -p<Privileged account password of the destination instance> <Database name of the destination instance> < /tmp/<Name of the database to be migrated>.sql
    mysql -h <Public IP address of the destination instance> -P <Port of the destination instance> -u <Privileged account of the destination instance> -p<Privileged account password of the destination instance> <Database name of the destination instance> < /tmp/<Name of the database to be migrated>trigger.sql

    Examples:

    mysql -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test2 -pTest2xxx test001 < /tmp/testdb.sql
    mysql -h rm-xxx.mariadb.rds.aliyuncs.com -P 3306 -u test2 -pTest2xxx test001 < /tmp/testdbtriggertrigger.sql