PostgreSQL → MySQL
Convert PostgreSQL text to MySQL
PostgreSQL's text is unlimited, so the only always-safe MySQL target is LONGTEXT (4 GB). Indexes on such columns need MySQL's prefix-length syntax.
text → LONGTEXT
What to know
- text → LONGTEXT (utf8mb4) — never truncates
- Indexes get a prefix: KEY (col(191)) — full-column indexes on LONGTEXT aren't allowed
- varchar(n) stays VARCHAR(n) when n is small enough for the row-size limit
- Literal defaults on TEXT columns must use MySQL 8 expression-default syntax — handled automatically
Before / after
PostgreSQL
CREATE TABLE posts (
body text
);
CREATE INDEX idx_body ON posts (body); MySQL
CREATE TABLE posts (
body LONGTEXT,
KEY idx_body (body(191))
); 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.