Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

MySQL CDC with Auto Table Creation

Use FROM MYSQL ... TO DATABASE to mirror one or more MySQL tables into an existing VeloDB Cloud database. The Streaming Job creates a Unique Key table for each selected source table, using the MySQL primary key. It can load the current rows and then continuously apply changes from the binary log. Delivery is at least once.

For a single table that needs SQL transformations, see MySQL CDC with SQL Mapping. To configure an import through the Console, see Import from MySQL.

SQL continuous load is experimental. Check Continuous Load Overview for warehouse availability.

Prerequisites​

  • Connect to the target warehouse and select a running compute cluster. Your warehouse SQL user needs LOAD_PRIV on the target database and CREATE_PRIV to create missing tables. For automatic column changes, grant ALTER_PRIV on the target tables.
  • Confirm that the warehouse can reach the MySQL host and port. For private connectivity, see the networking requirements in Import from MySQL.
  • Use source tables with primary keys. Enable row-based binary logging with full row images and grant the source account permission to read the selected tables and the binary log. For AWS sources, see Amazon RDS for MySQL or Amazon Aurora MySQL.
  • Identify a compatible MySQL JDBC driver available to the warehouse. Use a provisioned package name or an approved HTTPS URL. See JDBC Catalog.

1. Create the job​

The example copies two tables from the MySQL database shop into the warehouse database analytics. Replace the example endpoint, credentials, driver, and database and table names with your own.

USE analytics;

CREATE JOB mysql_orders_sync
ON STREAMING
FROM MYSQL (
"jdbc_url" = "jdbc:mysql://mysql.example.com:3306",
"driver_url" = "mysql-connector-j-8.3.0.jar",
"driver_class" = "com.mysql.cj.jdbc.Driver",
"user" = "cdc_reader",
"password" = "<source-password>",
"database" = "shop",
"include_tables" = "customers,orders",
"offset" = "initial"
)
TO DATABASE analytics;

If a target table already exists, the job uses it. Check that its columns and Unique Key are compatible with the source. For the types assigned to newly created tables, see MySQL data type mapping.

2. Check progress​

SELECT Name, Status, CurrentOffset, LoadStatistic, ErrorMsg
FROM jobs("type" = "insert")
WHERE Name = 'mysql_orders_sync' AND ExecuteType = 'STREAMING';

Check that Status is RUNNING. As MySQL commits changes, CurrentOffset advances through the binary log. Compare a source row with its counterpart in the warehouse to verify the import. For task history and pause, resume, or drop commands, see Continuous Load Overview.

3. Update source credentials​

After rotating the MySQL user's password, pause the job, update the credentials, and resume synchronization.

PAUSE JOB WHERE jobname = 'mysql_orders_sync';
ALTER JOB mysql_orders_sync
FROM MYSQL (
"user" = "cdc_reader",
"password" = "<new-source-password>"
)
TO DATABASE analytics;
RESUME JOB WHERE jobname = 'mysql_orders_sync';

Source settings​

PropertyDescription
jdbc_url, driver_url, driver_classMySQL JDBC URL, warehouse-accessible driver package, and driver class.
user, passwordCredentials for the MySQL replication account.
databaseSource MySQL database.
include_tablesComma-separated source table names. If you omit both table filters, every source table is selected. Job creation fails if any selected table lacks a primary key.
offsetUse initial for a snapshot followed by ongoing changes, or latest (the default) for future changes only. Core 26.1.1 and later also support snapshot for an initial load only.
snapshot_split_sizeNumber of rows per snapshot split. The default is 40,960 in Core 26.1.2 and later.
snapshot_parallelismNumber of splits a snapshot task can process concurrently. Core 26.1.4 and later choose a default based on available compute capacity. Earlier versions default to 1.
table.<source_table>.exclude_columnsIn Core 26.1.1 and later, exclude the specified source columns. Keep the source primary key. If a non-key column has an unsupported type, create the compatible target before excluding the column. Automatic table creation validates source types before it excludes columns.
table.<source_table>.target_tableIn Core 26.1.1 and later, set the name of the target table.
schema_change_behaviorIn Core 26.1.4 and later, evolve (default) applies supported schema changes. Use ignore to manage the target schema yourself. See MySQL schema changes.
ssl_mode, ssl_rootcertUse require to encrypt the connection or verify-ca to validate the source certificate against a trusted CA. For verify-ca, have an administrator register the CA in the job database under the streaming_job file catalog with CREATE FILE and set ssl_rootcert to FILE:<file_name>.

Target database settings​

Add target properties in parentheses after TO DATABASE analytics.

PropertyDescription
table.create.properties.*Set supported table properties on newly created target tables.
load.strict_modeEnable strict mode for row conversion during loading.
load.max_filter_ratioMaximum allowed fraction of filtered rows, from 0 to 1. A value of 0 allows no filtered rows.

Troubleshooting​

SymptomWhat to check
The job cannot connect to MySQL.Check the source endpoint and port, the warehouse network route, and the MySQL account's host restriction.
Table creation fails.Verify that each source table has a primary key and that the warehouse SQL user has CREATE_PRIV on the target database.
The job pauses after a source schema change.Inspect ErrorMsg and compare the affected columns with the supported schema changes.
The required binary log is missing.Compare the job offset with the logs MySQL still retains. A purged offset can require a new initial snapshot. Increase retention to cover expected outages.

See also​