MySQL to MatrixOne: runnable sample lab

Use independent MySQL 8.0 and MO v4.2.5 test instances with unused lab names. Suspend source writes during copying. This lab does not verify production CDC or snapshot/log handoff. Connect with each client and record SELECT VERSION().

Create source and target

Run the DDL separately on both instances. The target must be empty and the script checks this. Do not run in production.

CREATE DATABASE mo_mysql_migration_lab;
USE mo_mysql_migration_lab;
CREATE TABLE orders(
    id BIGINT PRIMARY KEY,
    amount DECIMAL(20,4),
    label VARCHAR(100),
    nullable_value VARCHAR(30),
    raw_bytes VARBINARY(16),
    event_at DATETIME(6)
);

Insert the Decimal, Unicode, NULL/empty, binary, and microsecond samples only on MySQL:

INSERT INTO orders VALUES
(1,999999999999.1234,'空间😀',NULL,X'00FF','2026-01-01 08:00:00.123456'),
(2,0.0000,'quote,pipe|','',X'5C00','2026-01-02 08:00:00.000001'),
(3,-10.5000,'delete-me','value',X'616263','2026-01-03 08:00:00');

Copy and compare rows

Install PyMySQL, configure actual MYSQL_SOURCE_HOST/PORT/USER/PASSWORD and MO_TARGET_HOST/PORT/USER/PASSWORD environment variables, save this as mysql_to_mo_lab.py, and run it with Python. Do not print passwords; use identities restricted to the isolated databases.

import os
import pymysql

# Only run against isolated lab databases; neither table may contain business data.
source = pymysql.connect(
    host=os.environ['MYSQL_SOURCE_HOST'], port=int(os.environ['MYSQL_SOURCE_PORT']),
    user=os.environ['MYSQL_SOURCE_USER'], password=os.environ['MYSQL_SOURCE_PASSWORD'],
    database='mo_mysql_migration_lab', charset='utf8mb4', autocommit=True)
target = pymysql.connect(
    host=os.environ['MO_TARGET_HOST'], port=int(os.environ['MO_TARGET_PORT']),
    user=os.environ['MO_TARGET_USER'], password=os.environ['MO_TARGET_PASSWORD'],
    database='mo_mysql_migration_lab', charset='utf8mb4', autocommit=True)
columns = 'id,amount,label,nullable_value,raw_bytes,event_at'
select_sql = 'SELECT ' + columns + ' FROM orders ORDER BY id'
try:
    with source.cursor() as cur:
        cur.execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ')
        cur.execute('START TRANSACTION WITH CONSISTENT SNAPSHOT')
        cur.execute(select_sql)
        rows = cur.fetchall()
    with target.cursor() as cur:
        cur.execute('SELECT COUNT(*) FROM orders')
        assert cur.fetchone()[0] == 0, 'target must be empty'
        cur.executemany('INSERT INTO orders VALUES(%s,%s,%s,%s,%s,%s)', rows)
        cur.execute(select_sql)
        actual = cur.fetchall()
    assert actual == rows, 'row/value reconciliation failed'
    print('Exact source/target rows match:', len(rows))
finally:
    source.rollback()
    source.close()
    target.close()

Expect 3 exactly matching rows. Binding avoids manual SQL replacement; Decimal values and raw bytes retain their driver representations. This single-table script reads everything into memory. Production needs streaming/partitioning and recoverable batches, not merely a larger input.

Negative control and manual replay

Change target id=2 amount to 1: counts still equal 3 but comparing each side with the script’s SELECT detects corruption. Repair only that test row. Then update source id=1, delete id=3, insert id=4, manually apply the corresponding changes on the target, and compare rows/key sets. This tests values/application semantics, not automatic CDC.

Define retry idempotency for deletions/inserts; repeating INSERT is not exactly-once. See migration workflow for cutover and connector requirements.

Cleanup and evidence

After the lab, drop only mo_mysql_migration_lab on both instances. The script executed on MySQL 8.0.44 and MO v4.2.5 with exact row comparison. Separate probes cover mysqldump/client import and quotes/newlines/binary/NULL. DBeaver/DataX and production CDC were not executed.