MySQL
Capture an initial MySQL load and ongoing changes into tapstate, then maintain application-ready operational state in MongoDB.
Connector profile
- Category
- Databases
- Guide maturity
- GAStable guide and configuration contract
- Role in this guide
- Source
- Capabilities
- SnapshotCDCSchema discoveryDDL capture
- Compatibility
- MySQL 5.0–9.x · Single node and primary-replica
Before you begin
Connector availability
The MySQL connector is registered automatically by the Quickstart script. On standalone or fresh server container deployments, the connector catalog starts empty. Confirm that MySQL is registered before authoring connections:
connectors
register mysqlSee When registration is required.
Source
Choose the outcome you need. Each tab is a complete preparation path; you do not need to combine steps from both tabs. In tapstate, a connection's mode describes what it can read: snapshot is a bounded full load and cdc is a change-capable source.
Ensure the tapstate runtime can reach the MySQL host and port. Prefer a private network path; when using a routed or internet path, allow only the runtime origin and protect the connection appropriately.
Create a connection
Tapstate stores the MySQL source as a .tap.yml file in the workspace.
The example below creates a CDC-capable source connection. The connection's mode controls its read capability.
tapstate new --non-interactive \
--kind source \
--connector mysql \
--id orders_source \
--mode cdc \
--set host=db.internal \
--set port=3306 \
--set database=orders \
--set username='${MYSQL_USER}' \
--set password='${MYSQL_PASSWORD}' \
--workdir tapstate-workFor a full-load-only source, change --mode cdc to --mode snapshot. The generated connection uses the same MySQL fields; only the read mode differs.
Edit tapstate-work/source/orders_source.tap.yml to select tables and the reading behavior:
version: tapstate/v1
kind: source
id: orders_source
connector: mysql
config:
deploymentMode: standalone
host: db.internal
port: 3306
database: orders
username: ${MYSQL_USER}
password: ${MYSQL_PASSWORD}
addtionalString: "useUnicode=yes&characterEncoding=UTF-8"
timezone: "+00:00"
mode: cdc
tables:
- orders
- /customers_.*/For a one-time full load, use mode: snapshot. For a CDC-capable source, use mode: cdc after completing the Binlog preparation. Before production, validate the intended full-load and CDC behavior in a staging pipeline.
Use a literal item such as orders for a fixed table. Use a /regex/ item to
discover matching tables; keep patterns narrow so a newly created table is not
included accidentally. Continue with the MongoDB target guide and
pipeline reference to complete the current product
path.
Use a primary-replica topology
Set deploymentMode: master-slave, then list the primary first. Use this path instead of standalone host and port.
config:
deploymentMode: master-slave
masterSlaveAddress:
- host: mysql-primary.internal
port: 3306
- host: mysql-replica-1.internal
port: 3306
database: orders
username: ${MYSQL_USER}
password: ${MYSQL_PASSWORD}For CDC from a replica, make sure it writes replicated events to its own binlog (log_slave_updates = 1). Check SHOW REPLICA STATUS (or SHOW SLAVE STATUS on older MySQL) and resolve replication lag before using it as a source.
Validate the configuration
Run validation after creating or editing the connection files:
tapstate validate --workdir tapstate-workvalid: 3 resources in tapstate-workThe resource shape, references, and applicable catalog rules were accepted. Runtime availability was not checked.
invalid: orders_source.tap.yml:12:1 dsl.unknown-field
Unknown field 'unexpected' at unexpected.Use the filename, location, diagnostic code, and suggested fix to update the resource.
Next, run the connection in a non-production environment and confirm credentials, network access, permissions, and a representative read or write.
The validation result shown above illustrates the CLI resource contract. Filenames, locations, resource counts, and error codes vary with the workspace.
Validation does not require all connection fields, reject unknown connector
keys, resolve secrets, or contact MySQL. A syntactically valid resource that
uses mysql.invalid can therefore pass validation.
To check the connection, register the MySQL connector JAR, apply the workspace, and run the test from an authenticated REPL:
tapstate -w tapstate-workconnect http://127.0.0.1:8080
login admin
apply
test orders_source -o jsonOnly outcome: PASSED establishes that the connector accepted the supplied
endpoint and credentials. A placeholder or unreachable host should produce
outcome: FAILED or a coded connector test error; the exact checks and timeout
come from the registered connector. See Register and test connectors
for the full sequence.
Limitations
Source limitations
- Only tables and indexes are in scope. Temporary tables, hidden columns, triggers, views, and stored procedures are not replicated.
- CDC parses the MySQL binlog and can increase source CPU and disk I/O under a high change rate. Monitor both resources during peak workloads.
- Keep Binlog files for at least seven days, and longer than the longest realistic outage or maintenance window. A CDC job cannot start or resume from a position that has expired or been deleted.
- Set
binlog_format = ROWandbinlog_row_image = FULL. Ensurebinlog-do-dbincludes the selected database andbinlog-ignore-dbdoes not exclude it. - Primary-replica addressing requires a planned failover test. Before a switchover, verify replication consistency,
log_slave_updates = 1on the replica used for CDC, and acceptable replica lag. - In MySQL 5.6 and earlier, normalize negative
TIMEvalues before CDC testing. - MySQL-compatible databases can add non-native schemas or functions that the MySQL parser does not understand. Test those variants before production use.
Consistency and conflicts
- Writes made outside the replication path can cause source-target differences.
- Avoid DDL on participating source tables during a snapshot. Schema changes can invalidate the snapshot or cause it to fail.
- Validate row counts and keyed samples after a snapshot, then test
INSERT,UPDATE, andDELETEevents before opening the target to consumers.
Reference
Connection settings
| Field | Required | Default | Use |
|---|---|---|---|
deploymentMode | No | standalone | Select standalone for one server or master-slave for a primary-replica list. |
host | With standalone | — | MySQL hostname or IP address. |
port | With standalone | 3306 | MySQL service port. Use a quoted string in .tap.yml. |
masterSlaveAddress | With master-slave | — | Ordered array of { host, port }; put the primary first. |
database | Yes | — | Database name. Create separate connections for separate databases. |
username | Yes | — | Database account name. |
password | No | — | Database password. Supply this from secret-aware environment handling. |
addtionalString | No | useUnicode=yes&characterEncoding=UTF-8 | Additional connection parameters. Use this exact field spelling; do not change it to additionalString. |
timezone | No | empty | UTC offset for timezone-naive values, for example +00:00 or +08:00. |
Data compatibility
| Category | Supported MySQL types |
|---|---|
| String | CHAR, VARCHAR, TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT, BINARY, VARBINARY |
| Integer | TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT |
| Numeric | DECIMAL, FLOAT, DOUBLE |
| Date and time | DATE, TIME, DATETIME, TIMESTAMP, YEAR |
| Large objects | TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB |
| Spatial | POINT, LINESTRING, POLYGON, GEOMETRY, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMCOLLECTION |
| Other | BIT, ENUM, SET, JSON |
- Current MySQL → MongoDB path:
TIMESTAMP(3)→ BSONDateat millisecond precision. Preserves the instant; does not preserve the source time-zone or offset representation. - Replicated row changes include
INSERT,UPDATE, andDELETE. - Adding, changing, renaming, and dropping columns remain pipeline-level staging checks.
- Test heterogeneous pipelines with spatial, custom,
ENUM, andSETvalues because downstream systems commonly represent them as strings.