PostgreSQL → MySQL
Convert PostgreSQL uuid to MySQL
MySQL has no uuid column type, so UUIDs are stored in their canonical 36-character text form. Defaults like gen_random_uuid() get a MySQL equivalent.
uuid → CHAR(36)
What to know
- uuid → CHAR(36) holding 'a1b2c3d4-…' text
- DEFAULT gen_random_uuid() → DEFAULT (uuid()) (MySQL 8.0.13+ expression default)
- Joins and lookups keep working — they're just string comparisons now
- Space-conscious alternative: BINARY(16) with UUID_TO_BIN(), at the cost of readability
Before / after
PostgreSQL
CREATE TABLE accounts (
uid uuid DEFAULT gen_random_uuid() NOT NULL
); MySQL
CREATE TABLE accounts (
uid CHAR(36) NOT NULL DEFAULT (uuid())
); Don't convert column-by-column — convert the whole database.
Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.
Open the PostgreSQL → MySQL converterSee the full type mapping table or all guides.