# Databases

> PostgreSQL, Redis, MongoDB and MySQL in one click — connection variables are written to your services automatically.

Source: https://livops.dev/en/docs/databases

A database runs in its own container inside a project environment. Once you add it, its address is written as a variable to **every service** in the environment — including services added later.

## Supported databases

| Database | Version | Main variable | Additional variables |
| --- | --- | --- | --- |
| PostgreSQL | 15, **16**, 17 | `DATABASE_URL` | `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE`, `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB` |
| Redis | 7 | `REDIS_URL` | `REDISHOST`, `REDISPORT`, `REDISPASSWORD` |
| MongoDB | **7**, 8.0 | `MONGO_URL` | `MONGODB_URI`, `MONGO_URI`, `MONGODB_URL`, `MONGOHOST`, `MONGOPORT`, `MONGOUSER`, `MONGOPASSWORD` |
| MySQL | 8.0, **8.4** | `MYSQL_URL` | `MYSQLHOST`, `MYSQLPORT`, `MYSQLUSER`, `MYSQLPASSWORD`, `MYSQLDATABASE`, `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_DATABASE` |

The version in bold is the default. You pick the version when you add the database; it **cannot be changed later** — to move to a newer version, add a new database of that version and copy the data over (`pg_dump`/`mysqldump`/`mongodump` over the SSH tunnel).

For example, for PostgreSQL:

```bash
DATABASE_URL=postgresql://app:<password>@postgres:5432/app
```

In your code, just read the variable:

```js
import pg from 'pg'
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
```

Where a bot or app on SQLite keeps its file: [Files and data](https://livops.dev/en/docs/files).

## Connecting

- A database is visible only from inside the project: the host is an internal name (`postgres`, `redis` ...). **No public port** — from your computer, only over an SSH tunnel (below).
- Browse tables on the database page in the cabinet.
- Each environment has its own databases: when `staging` is created, an **empty** copy of each database type in `production` is created — no data is copied.

## Connect with DBeaver/TablePlus over SSH

There is no public database port. Your own computer reaches the database through an SSH tunnel signed by your key — SSH has no password and no shell.

1. Create a key if you have none: `ssh-keygen -t ed25519`, then add the contents of `~/.ssh/id_ed25519.pub` in the cabinet under **Account → SSH keys**. Only ed25519 keys or RSA keys of at least 3072 bits are accepted.
2. Open the database page → **Connect from your computer**. Pick your client (DBeaver / DataGrip, TablePlus, pgAdmin, MongoDB Compass or Terminal).
3. Copy the **SSH** fields (host, port, user = the database's slug (its short name in the address), authentication = public key, private key `~/.ssh/id_ed25519`) and the **database** fields (host = the engine, e.g. `postgres`; port; database; user; password) into the client's own tabs.
4. Terminal: run the shown `ssh -N -L ...` command, keep it open, and connect to `localhost` with the shown address.

Only the project owner sees the password.

## Types: pgvector, PostGIS, Redis cache

When adding PostgreSQL or Redis you also choose its type. Like the version, it is fixed once the database exists.

| Type | What it is |
| --- | --- |
| PostgreSQL — Standard | The official image. Extensions from the list below. |
| PostgreSQL — with pgvector | Adds the `vector` extension: AI embeddings and similarity search. |
| PostgreSQL — with PostGIS | Adds `postgis` and `postgis_topology`: maps, coordinates, geometry. |
| Redis — Persistent (default) | Every write is kept on disk (AOF). When memory is full, new keys are refused rather than old ones lost. |
| Redis — Cache | Nothing on disk; when memory is full the least recently used keys are dropped (`allkeys-lru`). For sessions and caches only. |

A restored backup always lands in a copy of the **same** version and type.

## PostgreSQL extensions

On the database page → **Settings → Extensions**, the team owner switches extensions on and off. Only this list is offered:

`btree_gin`, `btree_gist`, `citext`, `cube`, `earthdistance`, `fuzzystrmatch`, `hstore`, `intarray`, `ltree`, `pg_trgm`, `pgcrypto`, `tablefunc`, `unaccent`, `uuid-ossp` — plus `vector` on a pgvector database and `postgis`, `postgis_topology` on a PostGIS one.

The app's login (`app`) is not a superuser: it owns its database and schema. Extensions that need a superuser (`vector`, `postgis`) are switched on with the toggle above; trusted ones (`pgcrypto`, `pg_trgm`, `uuid-ossp`, `citext`, …) also work from your own migrations.

An extension that a table or an index uses cannot be switched off — remove those first. TimescaleDB, `pg_stat_statements` and `pg_cron` are not available.

## Read-only login

For a BI tool (Metabase, Grafana) or an analyst, the team owner can create a login named `readonly` on the database page → **Overview → Read-only login** (PostgreSQL, MySQL, MongoDB). It can read every table, including ones created later, and cannot write anything. **New password** replaces the old one at once. Only the owner sees it.

## Connection limits and pooling

PostgreSQL accepts 20 connections at once, MySQL 30. Keep your app's pool small (Prisma: `?connection_limit=5` in `DATABASE_URL`). A built-in pooler (PgBouncer) is not offered yet.

## Sizes and pricing

| Size | Memory | Price per month |
| --- | --- | --- |
| 500 MB | 128 MiB | Free — one per team |
| 1 GB | 128 MiB | 9 credits (9,000 so'm) |
| 3 GB | 256 MiB | 19 credits (19,000 so'm) |
| 5 GB | 256 MiB | 29 credits (29,000 so'm) |

MySQL gets at least 256 MiB of memory and MongoDB at least 384 MiB, whatever the size: they do not start in less.

You can increase the size later. Current prices are shown in the cabinet's add-database dialog.

## Backups

PostgreSQL, MongoDB, MySQL and Redis databases are backed up automatically every night and stored in a separate location.

- Kept: the last **7 daily**, **4 weekly** and **3 monthly** backups.
- You can download any backup (PostgreSQL: a `pg_dump` custom-format file; MongoDB: a `mongodump --archive --gzip` file; MySQL: a gzipped `mysqldump` SQL file; Redis: an RDB file) or take a backup of the **current state** before risky work.
- **A restore never overwrites an existing database.** It opens as a new database next to the original, and your apps' variables don't change — check it, then switch over yourself.
- Only the team owner can restore, confirming by typing the database name.

A Redis backup is restored into a new Redis too, never into the running one.
