# Create databases and users

> Create databases, users and extensions from the dashboard, with passwords only you ever see.

Source: https://rowsafe.sh/docs/guides/databases-and-users

The **Databases & users** tab creates and removes databases, users and extensions inside a database server, without logging in to it. New databases are **backed up from the first second**.

Examples use PostgreSQL. See also [other engines](#mysql-mariadb-mongodb-and-clickhouse) and [Redis and Valkey](#redis-and-valkey).

## Create a database

1. Open the server, then **Databases & users**.
2. Click **Create database** and type a name, such as `shop`.
3. Click **Create database**.

You get the database (UTF-8) and a user of the same name that owns it, and only that user (and superusers) can connect. The password is shown **once**, with a connection string and snippets for `.env`, `psql`, Prisma, Django, Rails and Laravel. Copy it now: Rowsafe doesn't keep it.

**More options** lets you pick an **existing user** as owner, turn on **extensions**, or choose a **locale** or `template0`.

## Add a user

Click **Add user**, name it, and pick its databases and access:

| Access             | Can                                                                                    |
| ------------------ | -------------------------------------------------------------------------------------- |
| **Read only**      | Read every table, including tables the database's owner creates later. Change nothing. |
| **Read and write** | Also add, change and delete rows, and use sequences. Can't create or change tables.    |
| **Full access**    | Everything the owner can do, including creating and changing tables.                   |

The password is shown once.

## New password, remove a user

Open a user's menu:

- **New password** shows a new password once. Connected apps stay connected until they reconnect.
- **Remove user** ends its connections. What it owns goes to the user you choose.

Rowsafe never changes superusers or its own users.

## Extensions

Click **Extensions** in a database's menu to turn them on and off. You see what's installed on the server, plus [pgvector, PostGIS and TimescaleDB](#pgvector-postgis-and-timescaledb), which Rowsafe can install. Risky ones (like `plpython3u` or `file_fdw`) need you to type their name.

### pgvector, PostGIS and TimescaleDB

On PostgreSQL 15 to 18, **pgvector** (AI search), **PostGIS** (maps) and **TimescaleDB** (time series) are one switch each. Rowsafe installs the package, then turns it on.

- **TimescaleDB restarts PostgreSQL once** (a Mark first, a few seconds).
- **TimescaleDB is the Apache-2.0 edition**: no compression or continuous aggregates.
- **Only where root allowed PostgreSQL updates** ([permissions](https://rowsafe.sh/docs/guides/permissions)).
- **With a standby**, only extensions already installed can be turned on. On [servers Rowsafe creates](https://rowsafe.sh/docs/guides/rowsafe-cloud#extensions), pick them at creation.
- Pulse keeps them working and offers **Update** when a database runs an older version.

## Remove a database

Click **Remove database** in its menu and type its name. A **Mark** is saved first, so [Rewind](https://rowsafe.sh/docs/guides/restore) can bring it back. `postgres`, `template0` and `template1` can't be removed.

## From the CLI

```sh
rowsafe db                                  # databases, users and extensions
rowsafe db create shop                      # a new database and its own user; the password is shown once
rowsafe db create shop --owner app --extension pg_trgm
rowsafe db user add reporting --db shop --access read_only
rowsafe db user password reporting
rowsafe db user remove old_app --reassign-to app
rowsafe db ext on shop vector                # pgvector: installed first if needed
rowsafe db ext on metrics timescaledb --restart   # a Mark, then one restart of PostgreSQL
rowsafe db drop shop                        # asks you to type the name; a Mark first
```

Add `--on NAME` to pick the server. See the [CLI reference](https://rowsafe.sh/docs/reference/cli#databases-and-users).

## How passwords stay private

Rowsafe never sees the passwords it creates. The agent on your server makes the password and encrypts it to a one-time key in your browser (ECDH P-256, AES-256-GCM). Rowsafe relays it once and deletes it. PostgreSQL stores only a SCRAM verifier, so it isn't in any log.

## A database for an AI agent's app

An AI agent building an app on [Rowsafe Cloud](https://rowsafe.sh/docs/guides/rowsafe-cloud) needs its own database (see [Need a database?](https://rowsafe.sh/docs/guides/ai-agents#need-a-database)):

- **From a local `rowsafe mcp --allow-writes`, on PostgreSQL 15+**: the agent creates it with `create_app_database`, as the owner or admin who connected it. The password is made on your machine. Needs Rowsafe 0.9.4 or newer on the server.
- **Otherwise** (plugins, apps signed in with Rowsafe, MySQL, MariaDB, ClickHouse): the password must be made in your browser, so the agent asks you to create it here.

The connection string uses the server's name (like `x7kq2mfa3pzd.cloud.rowsafe.sh`) with TLS.

## MySQL, MariaDB, MongoDB and ClickHouse

The same page works for other engines.

- **MySQL and MariaDB**: the "owner" has every right on the database. New users may log in from any host (`'name'@'%'`); your firewall decides who reaches it.
- **MongoDB**: users live in `admin` (connect with `authSource=admin`). A new database appears once something is written to it.
- **ClickHouse**: users from configuration files (like `default`) are never changed. On servers Rowsafe creates, new users get at most 40% of memory.
- **Redis and Valkey**: users only, see [below](#redis-and-valkey).
- **OpenSearch**: a database is an index (or data stream); users get read-only, read-and-write or owner access on the indices you list. See [Users and roles](https://rowsafe.sh/docs/guides/opensearch#users-and-roles).
- **Qdrant**: users are API keys on chosen collections. Admin keys expire (30 days, up to 90). See [API keys](https://rowsafe.sh/docs/guides/qdrant#api-keys).
- **Meilisearch**: a database is an index; users are API keys. See [API keys](https://rowsafe.sh/docs/guides/meilisearch#api-keys).
- **Older installs** can only list: the page shows the root command that fixes it.

## Redis and Valkey

The page manages **ACL users**:

| Access             | Can                                                                                                                                                                                  |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Read only**      | Read keys. No writes, no pub/sub, nothing dangerous (`KEYS`, `CONFIG`...).                                                                                                           |
| **Read and write** | Read and change keys, run scripts, use pub/sub, read `INFO`. Can't flush data (`FLUSHALL`, `FLUSHDB`), change settings, manage users, or run `KEYS`, `DEBUG`, `SHUTDOWN` or modules. |
| **Admin**          | Every command, including settings, users and flushing all data.                                                                                                                      |

- **Keys it can use**: patterns like `session:*` keep apps apart. Empty means every key.
- Rowsafe never changes the `default` user or its own.
- **Numbered databases** (0 to 15) are listed, not created: give each app its own user or key prefix.
- Users survive restarts only if the server has an ACL or configuration file (often not in Docker). Replicas don't get users.
- **Older installs**: run the Rowsafe installer again (in Docker, `rowsafe-agent redis login`) so Rowsafe may manage users.

With the CLI, use `--keys` instead of `--db`:

```sh
rowsafe db user add sessions --keys "session:*" --access read_write
rowsafe db user add everything --keys "*" --access read_only
```

## Who can do it

- Owners, admins and read-write API keys. Others only see the list.
- AI agents can create a database for an existing owner, remove a database or user, or toggle an extension [as the person who connected them](https://rowsafe.sh/docs/guides/agent-autonomy), if an owner or admin. Removing needs a backup. New users and passwords are for people only, except [a database for an AI agent's app](#a-database-for-an-ai-agents-app).
- Every change is in the [audit log](https://rowsafe.sh/docs/guides/teams#audit-log), without passwords.

## Limits

- Extensions, templates and locales are PostgreSQL only.
- PostgreSQL 15 to 16 with TimescaleDB can't be upgraded through Rowsafe yet.
- Redis and Valkey: custom-rule users are listed and kept. Rowsafe doesn't manage Redis TLS.
- A new user can also connect to databases everyone may connect to (usually `postgres`, where it can read nothing). Rowsafe doesn't change `pg_hba.conf`.
- The agent must be online.
