# Import from MySQL (/docs/next/prisma-postgres/import-from-existing-database-mysql)

> For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL.

Import an existing MySQL database into Prisma Postgres, then use it with Prisma Next.

Location: Next > Prisma Postgres > Import from MySQL

Move an existing MySQL database into Prisma Postgres, then connect Prisma Next to it.

## Prerequisites [#prerequisites]

You need:

* the connection URL for the MySQL database you are importing from
* a Prisma Data Platform account
* `pgloader`
* Node.js 24 or newer

## 1. Create a Prisma Postgres database [#1-create-a-prisma-postgres-database]

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`.

## 2. Create a pgloader config [#2-create-a-pgloader-config]

Create `config.load`:

```text 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';
```

## 3. Import into Prisma Postgres [#3-import-into-prisma-postgres]

Run pgloader:

```shell
pgloader config.load
```

## 4. Add Prisma Next [#4-add-prisma-next]

From your app root, initialize Prisma Next:

  

#### bun

```bash
bunx prisma-next init
```

#### pnpm

```bash
pnpm dlx prisma-next init
```

#### yarn

```bash
yarn dlx prisma-next init
```

#### npm

```bash
npx prisma-next init
```

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

  

#### bun

```bash
bunx prisma-next contract infer --output ./prisma/contract.prisma
bunx prisma-next contract emit
bunx prisma-next db sign
```

#### pnpm

```bash
pnpm dlx prisma-next contract infer --output ./prisma/contract.prisma
pnpm dlx prisma-next contract emit
pnpm dlx prisma-next db sign
```

#### yarn

```bash
yarn dlx prisma-next contract infer --output ./prisma/contract.prisma
yarn dlx prisma-next contract emit
yarn dlx prisma-next db sign
```

#### npm

```bash
npx prisma-next contract infer --output ./prisma/contract.prisma
npx prisma-next contract emit
npx prisma-next db sign
```

## Next steps [#next-steps]

* Review table and column names in the inferred contract.
* Use the [PostgreSQL existing-project guide](https://www.prisma.io/docs/next/add-to-existing-project/postgresql) for the first Prisma Next query.
* Use the [full Prisma Postgres MySQL import guide](https://www.prisma.io/docs/prisma-postgres/import-from-existing-database-mysql) for deeper migration details.

## Related pages

- [`From the CLI`](https://www.prisma.io/docs/next/prisma-postgres/from-the-cli): Start a Prisma Next app with Prisma Postgres from the command line.
- [`Import from PostgreSQL`](https://www.prisma.io/docs/next/prisma-postgres/import-from-existing-database-postgresql): Import an existing PostgreSQL database into Prisma Postgres, then use it with Prisma Next.