Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Destinations

Connect MySQL as a destination

Create a MySQL service account and connect MySQL to an Artie pipeline. Artie writes to one destination database, or to one database per source schema.

Required settings

Artie asks for these connection values. Each field name matches its label in the Artie dashboard.

FieldDefaultWhat to enter
HostNoneThe IP address or host name of your MySQL server, for example server.example.com.
Port3306The port MySQL listens on.
Authentication methodStatic credentialsStatic credentials to sign in with a password. Role assumption to sign in with an IAM role, on Amazon RDS and Aurora.
UserNoneThe service account user, artie in the service account script.
PasswordNoneThe service account password. Required with Static credentials.
TLS modeDisabledDisabled, TLS (preferred) or TLS (required). TLS (preferred) uses TLS when available and falls back to an unencrypted connection.

Create a service account

In the Dashboard, pick the Authentication method that matches how the user signs in.

SQL
CREATE USER 'artie' IDENTIFIED BY 'password';

-- Allows Artie to merge data, create and alter destination tables, and clean up
-- its temporary tables.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON *.* TO 'artie';

Replace password with the password for the user.

Add MySQL to a pipeline

Run the service account script first: the setup has no Prepare destination step for MySQL. When you create a pipeline, the Destination section of the setup has these steps.

  1. Choose the destination

    In Choose destination, select MySQL.

  2. Choose how Artie reaches MySQL

    In Network access, choose how Artie reaches the database, for example an IP allowlist or an SSH tunnel.

    Artie skips this step when the pipeline reuses an existing MySQL connector.

  3. Enter the connection details

    In Connect and verify, enter the fields from Required settings.

  4. Choose the destination database

    In Schema name, select the database Artie writes to.

    If your source has schemas, a Schema control appears first with One schema and Multiple schemas. Multiple schemas replaces Schema name with Schema name prefix (optional). Destination database routing describes both.

  5. Verify the destination

    Select Verify destination. Artie shows “Destination verified”.

    If the pipeline has no tables yet, the button reads Test connection. A passing test shows “Connection works. Choose tables to finish verifying the destination.”

To change these settings on an existing pipeline, select Edit pipeline, then open the Destination: MySQL tab. Pause the pipeline first: the database settings are locked while it runs. After you change the database, move the pipeline’s tables to it in MySQL.

Destination database routing

In MySQL, schemas and databases are the same thing, so the Dashboard’s schema settings choose the destination database. When your source has schemas, choose where each replicated table goes:

Setup labelLabel on an existing pipelineResult
One schemaWrite to one schemaEvery table goes to the database in Schema name.
Multiple schemasWrite to multiple schemasEach table goes to a database named after its source schema.

When your source has no schemas, Artie writes every table to the database in Schema name.

Write to one schema

Select One schema and choose the destination database in Schema name. Artie writes every selected source table to that database, regardless of its source database.

A table from a source schema other than the pipeline’s default takes its schema as a prefix: accounting.actions becomes accounting_actions. See Destination table naming.

Select an existing database, or create one: type its name in Schema name and select Create “NAME”, where NAME is the name you typed. Artie runs CREATE DATABASE IF NOT EXISTS with the destination service account. The global grant in the service account script includes the required CREATE privilege.

For an existing database, the service account needs SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, and ALTER on that database. If you prefer a database-scoped grant for an existing database, use:

SQL
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
ON artie_replica.* TO 'artie';

To create a database with a database-scoped grant, grant on its name before you create it. MySQL accepts grants on a database that doesn’t exist yet, and CREATE on that database is enough to create it:

SQL
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
ON NEW_DATABASE.* TO 'artie';

Replace NEW_DATABASE with the name you type in Schema name.

In a database grant, _ and % are wildcards, so an unescaped name also matches similar names: NEW_DATABASE matches NEWXDATABASE too. To match one name exactly, wrap it in backticks and escape the wildcards, for example ON `new\_database`.*. A name with a hyphen also needs backticks.

Write to multiple schemas

Select Multiple schemas to preserve each source database as a separate destination database. Artie writes a table from each source database to the corresponding destination database. To prefix every destination database name, set Schema name prefix (optional).

For example, a source table in orders.events is written to orders.events, or to replica_orders.events when the prefix is replica_.

Turn on Create missing schemas and Artie creates each missing destination database when the pipeline deploys, which needs CREATE on each new database: the global grant, or a grant on each database name made before the pipeline deploys. On an existing pipeline, the setting reads Dynamically create namespaces. Otherwise, create every destination database before starting the pipeline, or verification fails on the missing ones. Artie creates and evolves tables within those databases. The service account needs the same table-management permissions on every destination database:

SQL
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
ON orders.* TO 'artie';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
ON replica_orders.* TO 'artie';

What Artie creates

Artie creates each destination table that doesn’t exist. Destination table names can be up to 64 characters.

For a batch of inserts and updates, Artie writes straight to the destination table with INSERT ... ON DUPLICATE KEY UPDATE. Three kinds of batch go through a temporary staging table first: batches with deletes, batches for tables with soft deletes, and batches with TOAST columns.

Staging tables are named __artie_SUFFIX_EXPIRY. SUFFIX is 5 random characters, and EXPIRY is a Unix timestamp 6 hours after creation. Artie drops them, which is why the service account needs DROP.

Data types

Artie creates columns with these MySQL types. Artie’s typing library covers how source types become Artie types.

When the source is also MySQL, Artie creates each column with its source column type instead. It uses this table for ENUM and SET columns, for source types it doesn’t map (such as spatial types), for a string primary key with no length or a length over 255, and for a column with no source type.

Artie typeMySQL type
IntegerBIGINT
Float, doubleDOUBLE
Decimal with precision up to 65 and scale up to 30DECIMAL(precision, scale)
Decimal with no precisionDECIMAL(65, 5)
Decimal with a higher precision or scaleTEXT
BooleanBOOLEAN
String, UUIDTEXT, or VARCHAR(255) for a primary key column
Struct, JSON, arrayJSON
DateDATE
TimeTIME(6)
Timestamp, with or without a time zoneDATETIME(6)
IntervalTEXT

Was this page helpful?