# Connection URLs (Prisma ORM v7) (/docs/orm/v7/reference/connection-urls) > 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. Learn about the format and syntax Prisma ORM uses for defining database connection URLs for PostgreSQL, MySQL and SQLite Location: ORM > v7 > Reference > Connection URLs Prisma ORM needs a connection URL to be able to connect to your database, e.g. when sending queries with [Prisma Client](https://www.prisma.io/docs/orm/v7/prisma-client/setup-and-configuration/introduction) or when changing the database schema with [Prisma Migrate](https://www.prisma.io/docs/orm/v7/prisma-migrate). The connection URL is provided via the `url` field of a `datasource` block in your Prisma config (or Prisma schema if on version 6). It usually consists of the following components (except for SQLite and [Prisma Postgres](https://www.prisma.io/docs/postgres)): - **User**: The name of your database user - **Password**: The password for your database user - **Host**: The IP or domain name of the machine where your database server is running - **Port**: The port on which your database server is running - **Database name**: The name of the database you want to use Make sure you have this information at hand when getting started with Prisma ORM. If you are starting a new project and don't have a database yet, you can get a connection URL without installing a database server. For a project that uses the `postgresql` provider, [`npx create-db`](https://www.prisma.io/docs/postgres/npx-create-db) creates a temporary [Prisma Postgres](https://www.prisma.io/docs/postgres) database from your terminal, without an account: ```bash npx create-db@latest ``` The command prints the direct connection string and a claim URL. It does not edit `.env`. In a new project where `DATABASE_URL` is not set yet or still holds the value that `prisma init` wrote, set the printed string as `DATABASE_URL`, the variable your Prisma config reads. The temporary database is deleted after 72 hours unless you claim it with a free Prisma account. For a database on your own machine, use a SQLite file (see the [Quickstart](https://www.prisma.io/docs/v7/prisma-orm/quickstart/sqlite)) or run `npx prisma dev` for a [local Prisma Postgres](#local-prisma-postgres) instance. If `DATABASE_URL` already holds the connection string of a database you use, keep that value. A new database does not fix a connection error with an existing one. ## Format [#format] The format of the connection URL depends on the *database connector* you're using. Prisma ORM generally supports the standard formats for each database. You can find out more about the connection URL of your database on the dedicated docs page: - [PostgreSQL](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/postgresql) - [MySQL](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/mysql) - [SQLite](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/sqlite) - [MongoDB](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/mongodb) - [Microsoft SQL Server](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/sql-server) - [CockroachDB](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/postgresql#cockroachdb) ### Special characters [#special-characters] For MySQL, PostgreSQL and CockroachDB you must [percentage-encode special characters](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding) in any part of your connection URL - including passwords. For example, `p@$$w0rd` becomes `p%40%24%24w0rd`. For Microsoft SQL Server, you must [escape special characters](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/sql-server#connection-details) in any part of your connection string. ## Examples [#examples] Here are examples for the connection URLs of the databases Prisma ORM supports: ### Prisma Postgres [#prisma-postgres] [Prisma Postgres](https://www.prisma.io/docs/postgres) is a managed PostgreSQL service running on unikernels. There are several ways to connect to Prisma Postgres: - via direct TCP connections (lets you connect via any ORM or database tool) - via pooled TCP connections (recommended for serverless and high-concurrency workloads) - via the hosted [Prisma Accelerate](https://www.prisma.io/docs/accelerate) connection (being phased out; see [Switch from Accelerate](https://www.prisma.io/docs/postgres/database/switch-from-accelerate)) - locally The connection string formats of these are covered below. #### Direct TCP [#direct-tcp] When you connect to Prisma Postgres via direct TCP, your connection string looks as follows: ```bash DATABASE_URL="postgres://USER:PASSWORD@db.prisma.io:5432/postgres?sslmode=require" ``` The `USER` and `PASSWORD` values are provided when you generate credentials for your Prisma Postgres instance in the [Prisma Console](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=orm). `npx create-db@latest` prints a complete connection string in this format for a temporary database (deleted after 72 hours unless you claim it). #### Pooled TCP [#pooled-tcp] When you connect to Prisma Postgres via pooled TCP, your connection string looks as follows: ```bash DATABASE_URL="postgres://USER:PASSWORD@pooled.db.prisma.io:5432/?sslmode=require" ``` Use a pooled TCP connection string for serverless, bursty, or high-concurrency workloads. Learn more in [Connection pooling](https://www.prisma.io/docs/postgres/database/connection-pooling). #### Via Prisma Accelerate (HTTP, retiring) [#via-prisma-accelerate-http-retiring] > [!WARNING] > Hosted Accelerate connection retirement > > The hosted `prisma+postgres://accelerate.prisma-data.net` connection keeps working after December 1, 2026, and we'll give at least 30 days' notice before it ends. New code should use pooled TCP or the serverless driver, and existing apps can [switch now](https://www.prisma.io/docs/postgres/database/switch-from-accelerate). > > This does not affect Local Postgres `prisma+postgres://localhost` URLs. When connecting via Prisma Accelerate, the connection string doesn't require a user/password like a conventional connection string does. Instead, authentication works via an API key: ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "prisma+postgres://accelerate.prisma-data.net/?api_key=API_KEY" }, }); ``` In this snippet, `API_KEY` is a placeholder for the API key generated by the [Prisma Console](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=orm). #### Local Prisma Postgres [#local-prisma-postgres] The connection string for connecting to a [local Prisma Postgres](https://www.prisma.io/docs/local-development/postgres) instance mirrors the structure of a remote instance via Accelerate: ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "prisma+postgres://localhost:51213/?api_key=__API_KEY__" }, }); ``` However, in this case the `API_KEY` doesn't provide authentication details. Instead, it encodes information about the local Prisma Postgres instance. You can obtain a local connection string via the [`prisma dev`](https://www.prisma.io/docs/orm/v7/reference/prisma-cli-reference#dev) command. ### PostgreSQL [#postgresql] ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "postgresql://janedoe:mypassword@localhost:5432/mydb?schema=sample" }, }); ``` ### MySQL [#mysql] ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "mysql://janedoe:mypassword@localhost:3306/mydb" }, }); ``` ### Microsoft SQL Server [#microsoft-sql-server] ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;" }, }); ``` ### SQLite [#sqlite] ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "file:./dev.db" }, }); ``` ### CockroachDB [#cockroachdb] ```ts title="prisma.config.ts" export default defineConfig({ datasource: { url: "postgresql://janedoe:mypassword@localhost:26257/mydb?schema=public" }, }); ``` ### MongoDB [#mongodb] *Support for MongoDB is limited to [Prisma 6](https://www.prisma.io/docs/orm/v6/reference/connection-urls#mongodb) as of now. We're working on support for MongoDB in Prisma v7* ## .env [#env] You can also provide the connection URL as an environment variable: ```prisma title="schema.prisma" datasource db { provider = "postgresql" } ``` You can then either set the environment variable in your terminal or by providing a [dotenv](https://github.com/motdotla/dotenv) file named `.env`. Prisma ORM 7 does not load `.env` files by itself: load the file explicitly, for example with `import "dotenv/config"` at the top of your Prisma config file (`prisma.config.ts`, or `prisma7.config.ts` in projects created with Prisma ORM 7.10 or later). See [Using environment variables](https://www.prisma.io/docs/orm/v7/reference/prisma-config-reference#using-environment-variables). `DATABASE_URL` is then read in the following situations: - When a Prisma CLI command such as `prisma migrate dev` runs: the CLI reads it through `datasource.url` in the Prisma config file - When your application connects to the database at run time: your code loads `.env` in the same way and passes the connection string to the driver adapter ``` DATABASE_URL=postgresql://janedoe:mypassword@localhost:5432/mydb ``` ## Related pages - [Config API](https://www.prisma.io/docs/orm/v7/reference/prisma-config-reference): Complete reference for prisma.config.ts configuration options - [Database Features](https://www.prisma.io/docs/orm/v7/reference/database-features): Database features supported in Prisma ORM - [Environment Variables](https://www.prisma.io/docs/orm/v7/reference/environment-variables-reference): Reference for Prisma environment variables - [Error Reference](https://www.prisma.io/docs/orm/v7/reference/error-reference): Prisma Client, Migrate, and Introspection error codes - [Prisma CLI reference](https://www.prisma.io/docs/orm/v7/reference/prisma-cli-reference): This page gives an overview of all available Prisma CLI commands, explains their options and shows numerous usage examples