Skip to content
migration.tools
PostgreSQL to MySQL

PostgreSQL to MySQL converter

Convert pg_dump output into MySQL-compatible SQL. COPY blocks are turned into INSERT statements, sequences into AUTO_INCREMENT, and PostgreSQL-only types into their closest MySQL equivalents.

Going the other way? MySQL to PostgreSQL

Options

PostgreSQL SQL

MySQL SQL

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Export your database (pg_dump) and paste the SQL, or drop the .sql file.
  2. 2Read the review notes under the output — they list everything that needs a human decision.
  3. 3Download the MySQL script and run it against a staging database first.

What changes between PostgreSQL and MySQL

COPY … FROM stdin data blocks — the pg_dump default — are expanded into multi-row INSERT statements, with \N turned into NULL and 't'/'f' into 1/0 for boolean columns.

SERIAL columns and nextval() defaults become AUTO_INCREMENT. CREATE SEQUENCE, setval(), OWNER TO, SET and extension statements are removed.

BOOLEAN becomes TINYINT(1), TEXT becomes LONGTEXT, BYTEA becomes LONGBLOB, JSONB becomes JSON, UUID becomes CHAR(36) and TIMESTAMPTZ becomes TIMESTAMP. ::type casts are stripped from defaults.

Primary keys and constraints that pg_dump writes as separate ALTER TABLE statements are folded back into the CREATE TABLE, and double-quoted identifiers become backticks.

What to check before you run it

Run the converted script against an empty staging database first, inside a transaction if the target supports transactional DDL. The review notes under the output list every statement that was dropped, every type with no direct equivalent and every clause that needs a manual decision.

Views, triggers, stored procedures and functions are passed through unchanged and flagged. Their bodies are written in PostgreSQL's procedural language and need a human rewrite for MySQL.

After loading, compare row counts table by table. For a deeper check, export a table from both databases and run the two files through the CSV compare tool.

Questions

My dump uses COPY instead of INSERT. Is that a problem?

No. COPY blocks are parsed and rewritten as INSERT statements, so you don't need to re-run pg_dump with --inserts.

What isn't converted?

Arrays, ranges, custom types, domains and PL/pgSQL functions have no direct MySQL equivalent. Columns using them keep the original type name and appear in the review notes.