> ## Documentation Index
> Fetch the complete documentation index at: https://midplane.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect a database

> Connect a Postgres or MySQL database to Midplane as a source: paste its connection string, choose how Midplane reaches it, test it, then give Midplane a role that can only read.

A source is a database your agents can ask. Midplane reads it live, over
TLS, and only reads. Owners and admins connect sources; members can ask for
one with **Request a source** on **Sources**.

## What you can connect

| Engine | Versions |
| - | - |
| Postgres | Tested on 17 and 18. |
| MySQL | 8.3 or later, tested on 8.4. |

The test refuses MySQL before 8.3, Aurora MySQL included (Aurora MySQL 3 is
MySQL 8.0), and MariaDB: Midplane checks every MySQL query's plan in a
format older servers lack. PlanetScale's MySQL (Vitess) isn't supported.
For anything else, such as Snowflake, use **Request a source**.

## What you need

* **A connection string**, a read replica's if you have one. Any user that
  can log in will do to start, an admin's included.
* **A way in**: the database accepts TLS connections from your region's
  egress addresses, or an SSH bastion that Midplane can reach does.

## Connect it

On **Sources**, select **Connect a database**.

**1. Paste the connection string**

**What Midplane understood** shows what it read before anything reaches
the database.

```text theme={null}
postgres://reader:<password>@db.example.com:5432/shop
```

![The connect form: a connection string hidden as dots, What Midplane understood (Postgres, host, port, database, user, TLS verified), the EU egress addresses to allow, and Test and connect.](https://mintcdn.com/midplane/A21NQSgjOLyH_XeA/images/connect.png?fit=max\&auto=format\&n=A21NQSgjOLyH_XeA\&q=85\&s=22975ce7047ca03b5ce8a62d52edd86a)

* Percent-encode `@`, `:`, `/`, `?`, `#` and `%` in the password (`@`
  is `%40`).
* A MySQL string ends with `/<database>`, where Midplane reads.
* File parameters such as `sslrootcert` show as **Ignored**: paste the
  certificate itself.

**2. Choose how Midplane reaches it**

**Directly, over TLS**: allow the two egress addresses the form shows,
if the database accepts only listed ones
([allowlists](https://midplane.ai/docs/connect/allowlist.md)). **Through an SSH bastion**, for a
private network: Midplane makes a key line for the bastion
([SSH bastions](https://midplane.ai/docs/connect/ssh.md)).

**3. Paste your CA certificate, if you run your own CA**

Midplane already trusts the public authorities, RDS and Aurora, and
Supabase. A certificate from any other CA verifies only once you paste
that CA here ([TLS](https://midplane.ai/docs/connect/tls.md)).

**4. Test and connect**

Midplane connects, checks the server's version, runs the role check and
reads the catalog (names and types, never a value), waiting up to 10
seconds. A failure says why in one sentence;
[connection problems](https://midplane.ai/docs/connect/troubleshooting.md) has a heading for each.

## Give Midplane its own role

Under **Midplane's role** on the source's page, make the role script, run
it as an admin and switch to it ([the role script](https://midplane.ai/docs/connect/role.md)).

## Review its sensitive columns

No one can query a source until someone reviews it: select **Review**,
check the masks Midplane suggests, and confirm ([the review](https://midplane.ai/docs/review.md)).

**Check:** the source's page says **Answering**, **TLS verified** and
**Reads only**.

> [accordion] If you need to change its credentials or remove it
>
> Under **Credentials**, paste a **New connection string** for the same
> host, port and database, and select **Test and replace**. Another
> database is a new source: the review and access were made for this one.
> **Remove**, at the foot of the page, deletes the source's credentials,
> SSH key and access; Activity keeps its entries.

## Your host

> [card] [Fly Managed Postgres](https://midplane.ai/docs/hosts/fly.md)

> [card] [Amazon RDS](https://midplane.ai/docs/hosts/rds.md)

> [card] [Amazon Aurora](https://midplane.ai/docs/hosts/aurora.md)

> [card] [Google Cloud SQL](https://midplane.ai/docs/hosts/cloud-sql.md)

> [card] [Neon](https://midplane.ai/docs/hosts/neon.md)

> [card] [Supabase](https://midplane.ai/docs/hosts/supabase.md)

> [card] [PlanetScale Postgres](https://midplane.ai/docs/hosts/planetscale.md)

> [card] [Your own server](https://midplane.ai/docs/hosts/self-hosted.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.