Migration from MySQL and PostgreSQL

From MemCP
Revision as of 12:14, 28 August 2026 by Wikiservice (talk | contribs) (Refresh MemCP documentation: accuracy, operational guidance, performance profile and maintained API reference)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Migration from MySQL and PostgreSQL

Migration is a compatibility and operations project, not only a data copy. MemCP can import through live MySQL/PostgreSQL connections or supported dump formats, while applications connect through the MySQL protocol or the HTTP SQL endpoints. It does not expose a PostgreSQL wire-protocol server and does not claim complete syntax, metadata, type, or administration compatibility with either source system.

Keep the source database authoritative until schema translation, row counts, constraints, representative queries, writes, timezone behavior, and restart recovery have been validated. Measure import duration and application latency with successful results, retain a rollback path, and separately design ongoing change capture when the source continues receiving writes during a staged migration.

MemCP client and import connection paths

Live import

; MySQL: host/port nil use 127.0.0.1:3306
(mysql_import nil nil "import_user" "secret" "source_db" "target_db")

; PostgreSQL: database, source schema, target database
(psql_import nil nil "postgres" "secret" "source_db" "public" "target_db")

Optional trailing arguments select or rename individual tables. Use a least-privilege read-only source account and protect credentials from shell and process listings.

Dumps

load_sql reads MySQL SQL; load_psql reads PostgreSQL SQL and supported pg_dump/archive inputs. A compressed input must be decompressed (zcat/xzcat), not passed through the gzip/xz compression functions.

gzip -dk dump.sql.gz
# Then in the MemCP console:
# (load_sql "target_db" (stream "dump.sql"))

For large or live migrations, prefer the importer functions above rather than assuming every vendor-specific dump statement is accepted.

Application connection

$db = new PDO(
    'mysql:host=127.0.0.1;port=3307;dbname=target_db',
    'root',
    'strong-password'
);
echo $db->query("SELECT 'it works'")->fetchColumn();

PostgreSQL SQL syntax is available over /psql/<database>; MemCP does not expose a PostgreSQL wire-protocol port.

Validation checklist

  • compare schemas, types, defaults, indexes, constraints, triggers, and views;
  • compare counts and checksums per table;
  • replay representative reads and writes against both systems;
  • verify AUTO_INCREMENT and timezone behavior;
  • restart MemCP and repeat checks;
  • measure import duration, query latency, errors, and CDC lag if live replication is used;
  • retain a tested rollback path until cutover gates pass.