Before you begin
Ensure you have the following:- A MySQL database (versions 5.7, 8.0+ supported)
- A CockroachDB cluster (Cloud or Self-Hosted)
- Network connectivity between source and target databases
- Appropriate user permissions on both databases
Installation
Install the MOLT CLI tools:Migration workflow
Convert the schema
Use the MOLT Schema Conversion Tool to convert your MySQL schema to CockroachDB-compatible DDL.
The Schema Conversion Tool is available in the CockroachDB Cloud Console under the Migrations page.
Key schema differences
MySQL and CockroachDB have important differences:| MySQL | CockroachDB | Notes |
|---|---|---|
AUTO_INCREMENT | DEFAULT unique_rowid() or gen_random_uuid() | Use UUID for better distribution |
INT (32-bit) | INT4 or INT8 | CockroachDB INT defaults to 64-bit |
DATETIME | TIMESTAMPTZ | Store with timezone |
TINYINT(1) | BOOL | For boolean values |
ENUM | STRING with CHECK or custom ENUM type | Must be explicitly defined |
Apply the schema
Load data with MOLT Fetch
Set connection strings
MySQL connection strings use
mysql:// protocol and tcp() format for host:port.For bulk load (with downtime)
Perform a one-time bulk load:MySQL doesn’t use schema namespaces like PostgreSQL. Tables are migrated to CockroachDB’s default
public schema.For minimal downtime migration
Load data and capture GTID checkpoint:Verify data consistency
Use MOLT Verify to confirm data consistency:MOLT Verify checks:
- Table structure and column definitions
- Row counts
- Row-level data consistency
Start continuous replication (optional)
For minimal downtime migrations, start MOLT Replicator to replicate ongoing changes.Key metrics to monitor:
Create table filter userscript (if needed)
If you filtered tables during the initial load, create a userscript to filter tables on replication:table_filter.ts
Start replication
Use the GTID from the fetch checkpoint:Monitor replication
Access replication metrics at:replication_lag_seconds: Time lag between source and targetmutations_applied: Number of changes appliedbinlog_position: Current position in MySQL binary log
Recreate constraints and indexes
After data load completes, recreate the constraints and indexes you dropped:
Cutover to CockroachDB
Pre-cutover checklist
- Verify data consistency with MOLT Verify
- Confirm replication lag is minimal (if using replication)
- Test application queries on CockroachDB
- Update application code for any MySQL-specific syntax
- Prepare rollback plan
Cutover procedure
- Stop application writes to the source database
- Wait for replication to drain (if using continuous replication)
- Run final verification with MOLT Verify
- Update connection strings in your application to point to CockroachDB
- Start application traffic on CockroachDB
Application compatibility
Connection drivers
CockroachDB uses PostgreSQL drivers, not MySQL drivers. Update your application:SQL syntax differences
Troubleshooting
Connection issues
MySQL connection errors
MySQL connection errors
Ensure your MySQL connection string uses the correct format:For SSL connections:
GTID not enabled
GTID not enabled
If GTID is not enabled, you’ll see an error during replication setup:
Performance issues
- Increase concurrency: Use
--table-concurrencyand--export-concurrencyflags - Adjust batch sizes: Use
--row-batch-sizeto tune shard size - Monitor binlog retention: Ensure binlog retention is sufficient for migration duration
Data type incompatibilities
Integer size differences
Integer size differences
MySQL
INT is 32-bit, but CockroachDB INT defaults to 64-bit:ENUM type conversion
ENUM type conversion
MySQL ENUM types must be converted:
Next steps
Schema Design
Optimize your schema for CockroachDB
Migration Strategy
Plan your migration approach