# Create and connect to a database

> Create a Postgres database and connect with psql over TLS

> Nevia is in beta and open to selected teams. Public launch in Dec 2026. The CLI installs with `curl -fsSL https://get.nevia.cloud | sh`, and the MCP server is at https://api.nevia.cloud/mcp. A person signs in once in the browser.
> Setup, sign-in and requesting access: [SKILL.md](https://nevia.cloud/SKILL.md). When Nevia fits and when it doesn't: [why.md](https://nevia.cloud/why.md).

> For the complete documentation index, see [llms.txt](https://nevia.cloud/llms.txt). This page's HTML version: https://nevia.cloud/docs/databases/create

Create `orders` and run a query to check the connection.

You need [the CLI installed and signed in](https://nevia.cloud/docs/get-started/quickstart.md), `psql` on your
machine, and a [selected workspace](https://nevia.cloud/docs/workspaces/select.md) where you have the
admin or editor role. The name `orders` must be free in that workspace.

## Create

This uses the platform's default Postgres version and storage, and the default
`small` size:

```bash
nevia pg create orders --wait
nevia pg status orders
```

The state should be `ready`, with no pending transition. `--wait` waits up to
10 minutes. If it times out, creation continues, so [track the operation](https://nevia.cloud/docs/guides/operations.md)
before you go on.

Creation prints the connection and its new password. Save the password if another
client needs it. Status and list output omit credentials, but `pg connect` can
read the password back from the machine's configuration.

See [`nevia pg create`](https://nevia.cloud/docs/reference/cli/pg/create.md) for version, size and
storage options.

## Connect

Print the connection details:

```bash
nevia pg connect orders
```

This prints the host, port, database, user, password and TLS mode. It doesn't
open a SQL session. Add `--uri` to pass the connection to `psql`:

```bash
psql "$(nevia pg connect orders --uri)" -c 'SELECT 1;'
```

You should see one row containing `1`. That confirms the connection works from
your machine; `ready` only says the guest is up.

Keep the URI's `sslmode=require` or a stricter setting, because routing requires
TLS. If the server reports that SSL is unavailable, the deployment needs TLS
configured before this connection works.

If `pg connect --uri` reports no dialable URI, the host or password is unavailable.
Run `nevia pg status orders`. A host reachable only inside the cluster needs
deployment networking that allows access from your machine. A sleeping database
needs an [explicit wake](https://nevia.cloud/docs/databases/lifecycle.md) before SQL connections
work. Retrieving credentials doesn't wake it.

## Reset the password

Reset the password if you lost it, or if `pg connect` reports it as `untracked`
because someone changed it in SQL:

```bash
nevia pg reset-password orders
```

The command asks for confirmation; `--yes` approves. The current password stops
working, including one set in SQL, and the command prints a new one. A sleeping
database keeps its old password until it wakes. The reset applies then, and no
password shows until it does. Reset needs a database that is not creating or
changing state. In MCP, the `reset_database_password` tool does the same; see
[Databases](https://nevia.cloud/docs/reference/mcp.md#databases) in the Remote MCP server reference.

## Use the console's Connect card

In the [console](https://console.nevia.cloud/), select the same workspace, open
**Databases**, then **orders**. The **Connect** card offers three forms:

* **Connection**: copy the URI, or the host, port, database, user and password
  fields separately. The card also shows the required TLS mode.
* **Code**: choose **psql** for a command that uses the URI, or pick an
  application snippet.
* **Agent**: copy a prompt that contains the URI and instructions to verify the
  connection over TLS.

The URI and the agent prompt include the password.

## Next steps

[Branch the database](https://nevia.cloud/docs/databases/branch.md) to work on a copy, or
[sleep, wake and delete it](https://nevia.cloud/docs/databases/lifecycle.md). See
[Database lifecycle states](https://nevia.cloud/docs/reference/database-lifecycle.md) for connection
and persistence constraints.
