Import from MySQL
Move an existing MySQL database into Prisma Postgres, then connect Prisma ORM to it.
You need:
- the connection URL for the MySQL database you are importing from
- a Prisma Data Platform account
pgloader- Node.js 24 or newer
Create a Prisma Postgres database from Console or with the CLI. Copy the direct connection string. You will use it for the import and for DATABASE_URL.
Create config.load:
LOAD DATABASE
FROM mysql://USER:PASSWORD@HOST:PORT/DATABASE
INTO postgres://USER:PASSWORD@db.prisma.io:5432/?sslmode=require
WITH quote identifiers,
include drop,
create tables,
create indexes,
reset sequences
ALTER SCHEMA 'DATABASE' RENAME TO 'public';Run pgloader:
pgloader config.loadFrom your app root, initialize Prisma ORM:
bunx prisma@latest orm initpnpm dlx prisma@latest orm inityarn dlx prisma@latest orm initnpx prisma@latest orm initChoose PostgreSQL, set DATABASE_URL to the Prisma Postgres connection string, then infer and emit the contract:
bunx prisma contract infer --output ./prisma/contract.prisma
bunx prisma contract emit
bunx prisma db signpnpm prisma contract infer --output ./prisma/contract.prisma
pnpm prisma contract emit
pnpm prisma db signyarn prisma contract infer --output ./prisma/contract.prisma
yarn prisma contract emit
yarn prisma db signnpx prisma contract infer --output ./prisma/contract.prisma
npx prisma contract emit
npx prisma db sign- Review table and column names in the inferred contract.
- Use the PostgreSQL existing-project guide for the first Prisma ORM query.
- Use the full Prisma Postgres MySQL import guide for deeper migration details.