This topic describes how to use AnalyticDB for MySQL external tables and the INSERT INTO statement to export data from AnalyticDB for MySQL to MySQL.
Prerequisites
- An ApsaraDB RDS for MySQL instance is created, a whitelist is configured, and an account,
a databases, and tables are created. For more information, see Quick start of ApsaraDB RDS MySQL.
Note The ApsaraDB RDS for MySQL instance and AnalyticDB for MySQL cluster must be in the same VPC. You must add the CIDR block of this VPC to the whitelist of the ApsaraDB RDS for MySQL instance. In this case, the AnalyticDB for MySQL database can use the VPC endpoint of the ApsaraDB RDS for MySQL instance to access the ApsaraDB RDS for MySQL database.
In this example, a table named courses is created in the test_adb database in ApsaraDB RDS for MySQL to store the data exported from AanlyticDB for MySQL.
CREATE TABLE courses ( id bigint NOT NULL, name varchar(32) NOT NULL, grade varchar(32) NOT NULL, submission_date timestamp NOT NULL, PRIMARY KEY (id) )
- An AnalyticDB for MySQL cluster is created, a whitelist is configured, and an account
and a database are created. For more information, see Quick start of AnalyticDB for MySQL.
In this example, the data in the courses table of the adb_demo database in AnalyticDB for MySQL is exported to the courses table of the test_adb database in ApsaraDB RDS for MySQL.
create Table courses ( id bigint AUTO_INCREMENT, name varchar NOT NULL, grade varchar DEFAULT 'Grade 3', submission_date timestamp ) DISTRIBUTE BY HASH(id)
insert into courses (name,submission_date) values("Jams",NOW());
Note If AnalyticDB MySQL cluster is in elastic mode, log on to the AnalyticDB MySQL console and view the cluster information. Enable Elastic Network Interface (ENI) in the Network
Information section.

Background information
Note The MySQL database in this topic can be an ApsaraDB RDS for MySQL database or a user-created
ECS-hosted MySQL database.