# Databases

> MariaDB and PostgreSQL databases per subscription, users that span several databases, import and export, remote access with TLS, PostgreSQL extensions, Adminer on its own hostname with a one-time login, anonymised copies, and the limits and slow-query report that keep a shared server fair.

Source: https://www.berthpanel.app/library/databases/ · Category: data · Updated: 2026-10-30

Every subscription can have its own MariaDB and, when the package allows it, PostgreSQL databases. This page covers creating databases and users, connecting from a site or from outside, importing and exporting, managing them in the browser with Adminer, making an anonymised copy for testing, and the limits that stop one site from slowing down the rest. Going back to an earlier moment is described in [Point-in-time restore](https://www.berthpanel.app/library/point-in-time-restore/).

## MariaDB and PostgreSQL

Berth uses the database servers of the operating system: on Debian 13 that is MariaDB 11.8 and PostgreSQL 17. MariaDB is always available; PostgreSQL databases can be created when the package allows them (`berth plan set … --postgresql`). Each database belongs to one subscription and counts towards its disk space.

## Creating a database

1. Go to *Databases* in the menu and click **Add database**.
2. Choose the subscription.
3. Enter a name: lowercase letters, digits and `_`. It automatically gets the subscription's prefix, for example `acme_wp`.
4. Leave the username empty to use the database name, and the password empty to have a strong one generated.
5. Optionally choose **PostgreSQL** instead of MariaDB.
6. Create it. The credentials are shown **once** under *Credentials: write them down now*.

```bash
berth database create --sysuser acme --name wp
berth database create --sysuser acme --name app --user appuser --engine postgresql
berth database list
```

A new password for a database user is **New password** in the database's row, or `berth database password --database acme_wp --user acme_wp`. Deleting a database (**Delete…**) removes it with all its content; a user that also has other databases keeps those.

## One user for several databases

Some applications need one user for several databases, like Plesk's "all databases" user. Under *Users* on the same page:

- **Add user**: choose a name and tick the databases, all from the same subscription. With **Also every new database** the user automatically gets access to databases the subscription creates later. The password is shown once.
- **Databases…** next to a user adds or removes a database. Removing takes away the rights on that one database only. The last database cannot be removed; delete the user instead.

A user can never be given a database of another subscription. That is checked independently in the panel and again in the privileged agent that applies the grants.

```bash
berth database user create --sysuser acme --user report --database acme_shop --database acme_blog
berth database user grant --user acme_report --database acme_crm
berth database user revoke --user acme_report --database acme_blog
berth database user list
```

## Connecting

The card *Connect* on the *Databases* page shows how to connect:

| From | Host | Port |
|---|---|---|
| The website, MariaDB | `localhost` | 3306 |
| The website, PostgreSQL | `127.0.0.1` | 5432 |
| Outside the server | the address shown on the card | as shown |

The same card shows the subscription's **query time** (see [Limits](#limits-that-keep-a-shared-server-fair)).

## Remote access

To connect from your own computer or another server, open *Remote access…* in the database's row.

1. Choose **Only these IP addresses** and enter the addresses or networks, one per line, for example `203.0.113.10` or `203.0.113.0/24`. PostgreSQL also accepts IPv6 networks.
2. Keep TLS on. PostgreSQL is always TLS-only (`sslmode=require` or stricter). For MariaDB TLS is the default and strongly recommended.
3. Click **Grant access**.

Customers can open access to single addresses or a limited network. Opening a database to every address is reserved for the administrator, who has to confirm it explicitly, and then always with TLS. Remote access also needs the server to listen from outside, which the administrator switches on once under *Server settings* on the same page; the panel firewall still applies.

```bash
berth database remote --database acme_wp --user acme_wp --host 203.0.113.0/24
berth database remote --database acme_wp --user acme_wp --host 203.0.113.0/24 --remove
berth database remote --on                  # MariaDB listens from outside (restarts MariaDB)
berth database remote --on --postgresql     # the same for PostgreSQL
```

## Import and export

- **Export** creates a compressed SQL dump (`.sql.gz`) with tables, views, triggers and routines.
- **Import…** reads a dump from phpMyAdmin, Plesk or `mysqldump`: `.sql`, `.sql.gz` or `.zip`. The import runs with the database's own rights, and `DEFINER` clauses are removed so views and triggers belong to this database. Tables that are in the file are overwritten, so export first if you might want to go back.

```bash
berth database export --name acme_wp -o acme_wp.sql.gz
berth database import dump.sql.gz --name acme_wp
```

## PostgreSQL extensions

PostgreSQL databases have an *Extensions* page, linked from the database's row. Create or remove extensions such as `pg_trgm`, `unaccent`, `hstore`, `citext`, `uuid-ossp`, `pgcrypto`, `postgis` and `vector` from the panel, without needing a superuser account yourself.

```bash
berth database extension --database acme_app
berth database extension --database acme_app --extension vector
```

## Adminer in the browser

The **Adminer** button in a database's row opens that database in [Adminer](https://www.adminer.org/) without typing a password. The panel creates a one-time login token and a temporary database user with rights on that one database only, so a session in Adminer can never see the subscription's other databases.

Adminer never runs on the panel's address. It has its own hostname, `adminer.<panel name>` by default, so a flaw in Adminer cannot reach a panel session, and it runs as its own system user. Point the name to the panel's address in DNS; the panel requests the certificate itself, and the card *Adminer on its own name* under *Settings* shows what is missing until then. Without its own name, Adminer stays off.

```bash
berth panel adminer-host                           # show, with the DNS records needed
berth panel adminer-host adminer.panel.example.nl
berth panel adminer-host --clear                   # switch Adminer off
```

## Anonymised copy for development

*Anonymised copy…* creates a new database with the content of an existing one, with personal data replaced, so developers and testers can work with realistic data without real customers in it. It works for MariaDB and PostgreSQL.

- Per column you choose a replacement: `email`, `name`, `username`, `phone`, `address`, `ip`, `text`, `empty` or `null`. A whole table can be emptied with `truncate`.
- Presets for **Laravel** and **Drupal** fill in the usual columns (only those that exist).
- The source database is never changed. If any step fails, the copy is removed again, so a half-anonymised copy never stays behind. The rules you used are remembered for next time.

```bash
berth database anonymize --from acme_shop --name shop_dev --preset laravel \
  --rule "orders.notes text" --rule "sessions truncate"
berth database anonymize --from acme_shop --show
```

## Limits that keep a shared server fair

The database servers are shared by all subscriptions, so Berth keeps one site from taking them over:

- **Query time.** A query from a database user may run for a limited time, five minutes by default, set per package (`--db-statement-seconds`) or per subscription. Longer queries are stopped by MariaDB or PostgreSQL, including writes and schema changes, which are rolled back; the site gets an error on that one query and keeps its connection. A watchdog in the panel also stops queries that run past their limit, and records it as an event on the subscription.
- **Connections.** The number of simultaneous connections is limited per database user and per subscription, configurable per package (`--db-user-connections`, by default 20 per user; `--db-connections`, by default 60 per subscription, which for PostgreSQL applies per database).
- **Disk space.** Databases count towards the subscription's disk space. When a subscription is far over its limit, its databases are locked for writing: MariaDB databases can still be read and cleaned up with `DELETE`, `DROP` and `TRUNCATE`, and PostgreSQL databases become read-only. The customer is notified, and the lock lifts by itself shortly after the subscription is back under its limit.

Customers who structurally need more, for example for a large migration, ask their hosting provider for a higher query time.

## Performance and slow queries

The *Performance* tab shows slow queries per database, grouped by shape: queries are normalised, so literal values (and any personal data in them) never appear, and similar queries count together. Many rows examined per query usually points to a missing index.

For the administrator the same tab shows how MariaDB is running, with advice and settings for the buffer pool, connections, temporary tables, the table cache and the slow log. Changes apply without a restart where possible; a restart of MariaDB can be scheduled in the [maintenance window](https://www.berthpanel.app/library/os-updates-and-maintenance/). Database load and storage per database over time are part of [Statistics and metrics](https://www.berthpanel.app/library/statistics-and-metrics/).

On install and update, Berth sizes MariaDB to the server, including the buffer pool, a thread pool, connections and room for temporary tables, so a new server does not start with the distribution's minimal defaults; your own tuning always wins.

```bash
berth database slow --sysuser acme
berth database tuning
berth database tuning --slow-log on --slow-ms 500
```

An administrator can also switch on a faster write mode for MariaDB (`berth database tuning --fast-commit on`, off by default). It makes writes cheaper, at the cost of up to one second of transactions if the whole server crashes; a crash of MariaDB alone loses nothing.

## MariaDB behaviour for websites

Sites that grew up on an older, non-strict MySQL sometimes rely on warnings instead of errors. *Behaviour for websites* under *Server settings* chooses between **modern** (utf8mb4, strict SQL mode) and **like the migration source**. Without a migration the behaviour is modern; the first migration takes over the behaviour of its source. Berth's own connections always use utf8mb4 and strict mode. Changing it restarts MariaDB, and if that fails the previous behaviour comes back.

```bash
berth database behaviour
berth database behaviour --modern
```

## Backups

Databases are part of every subscription backup, and can be restored on their own, next to the original or over it. See [Restoring data](https://www.berthpanel.app/library/restoring-data/) and, for going back to a precise moment, [Point-in-time restore](https://www.berthpanel.app/library/point-in-time-restore/).
