Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

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:

title="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.load

From your app root, initialize Prisma ORM:

title="bun"
bunx prisma@latest orm init
pnpm
pnpm dlx prisma@latest orm init
yarn
yarn dlx prisma@latest orm init
npm
npx prisma@latest orm init

Choose PostgreSQL, set DATABASE_URL to the Prisma Postgres connection string, then infer and emit the contract:

title="bun"
bunx prisma contract infer --output ./prisma/contract.prisma

bunx prisma contract emit

bunx prisma db sign
pnpm
pnpm prisma contract infer --output ./prisma/contract.prisma
pnpm prisma contract emit
pnpm prisma db sign
yarn
yarn prisma contract infer --output ./prisma/contract.prisma
yarn prisma contract emit
yarn prisma db sign
npm
npx prisma contract infer --output ./prisma/contract.prisma
npx prisma contract emit
npx prisma db sign
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu