Skip to main content

MySQL

VeloDB Cloud provides the following ways to load data from MySQL:

  • Loading MySQL data via JDBC Catalog

VeloDB Cloud uses JDBC Catalog to map MySQL as an external catalog, allowing direct SQL queries against MySQL data. Combined with INSERT INTO or CREATE TABLE AS SELECT, this is suitable for one-time migration or periodic batch loading.

  • Continuously syncing MySQL data via Streaming Job

VeloDB Cloud uses Streaming Job to continuously sync full and incremental data from MySQL to VeloDB Cloud. By integrating Flink CDC reading capability, VeloDB Cloud keeps the job running, reads Binlog from MySQL and writes it to VeloDB Cloud tables with delivery semantics determined by the selected mode. Two modes are supported: SQL Mapping Sync and Auto Table Creation Sync. Available in the VeloDB Core 26.1 series (Public Preview).

  • Loading MySQL data via Flink Doris Connector

Use Flink Doris Connector together with Flink MySQL CDC for real-time synchronization. This is suitable for scenarios that require additional Flink stream processing logic. The connector also provides a one-click full-database synchronization tool. For details, see Flink Doris Connector.

  • Loading MySQL data via third-party tools

Data integration tools such as DataX, SeaTunnel, and CloudCanal offer source-specific transfer options. Batch and CDC support vary by tool and connector. Check the chosen tool before syncing data from MySQL to VeloDB Cloud.

In most cases, you can use JDBC Catalog directly for one-time data migration. When continuous full + incremental synchronization is required, Streaming Job is recommended.

Before you begin​

For a guided full and incremental import, see Import from MySQL. The console configures a native Streaming Job for supported sources and deployments. Use JDBC Catalog for batch copies, Streaming Job SQL for direct configuration, or an external Flink pipeline for custom stream processing. See Load Overview for how these methods relate.

Use a running warehouse and ensure it can reach the source database. Replace sample source hosts, credentials, and JDBC driver URLs. Use a source account with the required read or replication privileges and a warehouse SQL user with the required catalog, load, and create privileges. For SQL driver configuration, use a JDBC driver URL accessible to the warehouse and permitted by the service. Do not upload a JAR to a managed host. The linked catalog and import guides describe source-specific prerequisites.

Native MySQL and PostgreSQL CDC Streaming Jobs are available in the VeloDB Core 26.1 series, which is in Public Preview. Check your warehouse version and the selected mode before using the examples.

Load MySQL data via JDBC catalog​

Use JDBC Catalog to map MySQL as an external catalog, then use INSERT INTO or CREATE TABLE AS SELECT to load data. For detailed syntax, see JDBC MySQL Catalog.

Step 1: prepare data in MySQL​

CREATE TABLE test.students (
id INT PRIMARY KEY,
name VARCHAR(64),
age INT
);

INSERT INTO test.students VALUES (1, 'Emily', 25), (2, 'Bob', 30);

Step 2: create a catalog in your warehouse​

CREATE CATALOG mysql_catalog PROPERTIES (
"type" = "jdbc",
"user" = '<source-user>',
"password" = '<password>',
"jdbc_url" = "jdbc:mysql://<mysql-host>:3306/test",
"driver_url" = "<jdbc-driver-url>",
"driver_class" = "com.mysql.cj.jdbc.Driver"
);

Step 3: create the target table in your warehouse​

CREATE DATABASE IF NOT EXISTS doris_db;

CREATE TABLE doris_db.students (
id INT,
name VARCHAR(64),
age INT
)
UNIQUE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 1;

Step 4: load data with INSERT INTO​

INSERT INTO doris_db.students
SELECT id, name, age FROM mysql_catalog.test.students;

If the target table does not exist yet, you can also use CREATE TABLE AS SELECT to create the table and load data in one step:

CREATE TABLE doris_db.students
AS
SELECT * FROM mysql_catalog.test.students;

Step 5: verify loaded data​

SELECT * FROM doris_db.students;
+----+-------+------+
| id | name | age |
+----+-------+------+
| 1 | Emily | 25 |
| 2 | Bob | 30 |
+----+-------+------+

Continuously sync MySQL data via Streaming Job​

Streaming Job continuously reads MySQL Binlog via Flink CDC and writes it to VeloDB Cloud. Two modes are supported:

  • MySQL CDC with Auto Table Creation: VeloDB Cloud creates downstream tables automatically on first sync (use include_tables to sync one, several, or all tables). Provides at-least-once semantics.
  • MySQL CDC with SQL Mapping: target table must be pre-created in your warehouse. Supports flexible column mapping, data transformation, and exactly-once semantics.

Limitations​

  1. Source tables must have primary keys. Auto Table Creation Sync creates Unique Key target tables. For SQL Mapping Sync, pre-create a compatible Unique Key target table.
  2. Load privilege is required. Auto Table Creation Sync also needs Create privilege when auto-creating downstream tables on first run.
  3. Available in the VeloDB Core 26.1 series (Public Preview).

Prerequisites​

Before submitting a Streaming Job, Binlog must be enabled on the MySQL side and the user must be granted the corresponding REPLICATION privileges. For environment-specific setup steps, see:

Operation example: auto table creation sync​

auto table creation sync

Auto Table Creation Sync uses the FROM MYSQL ... TO DATABASE ... syntax. The target is a VeloDB Cloud database, and the downstream tables are automatically created on first sync.

Step 1: prepare data in MySQL​

CREATE TABLE test.students (
id INT PRIMARY KEY,
name VARCHAR(64),
age INT
);

INSERT INTO test.students VALUES (1, 'Emily', 25), (2, 'Bob', 30);

Step 2: create the target database in your warehouse​

Auto Table Creation Sync does not require pre-creating tables, but the target database that hosts them must exist:

CREATE DATABASE IF NOT EXISTS doris_db;

Step 3: create a Streaming Job​

The example below uses include_tables to sync only the students table (multiple tables can be comma-separated; leave empty to sync the whole database):

CREATE JOB mysql_db_sync
ON STREAMING
FROM MYSQL (
"jdbc_url" = "jdbc:mysql://<mysql-host>:3306",
"driver_url" = "<jdbc-driver-url>",
"driver_class" = "com.mysql.cj.jdbc.Driver",
"user" = '<source-user>',
"password" = '<password>',
"database" = "test",
"include_tables" = "students",
"offset" = "initial"
)
TO DATABASE doris_db;

Step 4: check job status​

SELECT * FROM jobs("type"="insert") WHERE ExecuteType = "STREAMING";

Step 5: inspect auto-created VeloDB Cloud tables and loaded data​

SHOW TABLES FROM doris_db;
SELECT * FROM doris_db.students;

For more common operations and full parameter reference, see MySQL CDC with Auto Table Creation.

Operation example: SQL mapping sync​

SQL mapping sync

Step 1: prepare data in MySQL​

CREATE TABLE test.students (
id INT PRIMARY KEY,
name VARCHAR(64),
age INT
);

INSERT INTO test.students VALUES (1, 'Emily', 25), (2, 'Bob', 30);

Step 2: create the target table in your warehouse​

SQL Mapping Sync requires the target table to exist beforehand:

CREATE DATABASE IF NOT EXISTS doris_db;

CREATE TABLE doris_db.students (
id INT,
name VARCHAR(64),
age INT
)
UNIQUE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 1;

Step 3: create a Streaming Job​

Use CREATE STREAMING JOB with the INSERT INTO ... SELECT * FROM cdc_stream(...) syntax:

CREATE JOB mysql_students_sync
ON STREAMING
DO
INSERT INTO doris_db.students
SELECT * FROM cdc_stream(
"type" = "mysql",
"jdbc_url" = "jdbc:mysql://<mysql-host>:3306",
"driver_url" = "<jdbc-driver-url>",
"driver_class" = "com.mysql.cj.jdbc.Driver",
"user" = '<source-user>',
"password" = '<password>',
"database" = "test",
"table" = "students",
"offset" = "initial"
);

Step 4: check job status​

SELECT * FROM jobs("type"="insert") WHERE ExecuteType = "STREAMING";

Step 5: verify loaded data​

SELECT * FROM doris_db.students;

For more common operations (pause, resume, delete, check task, etc.) and full parameter reference, see MySQL CDC with SQL Mapping.