Databases

Built-in engines and your own database servers, with users, grants, snippets and a sign-in-free admin tool.

Available databases version 1.1.0 Part of Databases

Actions

63 actions, callable from the panel, the command palette and the API as POST /api/v1/a/<id>. Internal actions used between modules are not listed.

ActionWhat it doesRiskPreview
databases.engine.install Install a database engine critical
databases.engine.tune Size a database engine for this server high
databases.valkey.tune Size the panel's Valkey high
databases.engine.list List installed engines (read) low No dry run
databases.engine.offered Engines this account's server runs (read) low No dry run
databases.slowlog.list List slow queries (read) low No dry run
databases.query.run Run a statement medium
databases.maint.run Database maintenance medium
databases.db.create Create a database medium
databases.db.list List databases (read) low No dry run
databases.db.get Get a database (read) low No dry run
databases.db.stats Refresh database sizes low No dry run
databases.db.delete Delete a database high
databases.db.export Export a database low
databases.db.import Import a dump medium
databases.user.create Create a database user medium
databases.user.list List database users (read) low No dry run
databases.user.delete Delete a database user medium
databases.user.password.set Reset a user's password medium
databases.user.password.reveal Reveal a vaulted password (read) high No dry run
databases.grant.set Set a user's access to a database medium
databases.remote.set Allow remote connections high
databases.valkey.create Create a Valkey instance medium
databases.valkey.list List Valkey instances (read) low No dry run
databases.valkey.update Change a Valkey instance medium
databases.valkey.reset Reset a Valkey password medium
databases.valkey.stats Valkey usage (read) low No dry run
databases.valkey.delete Delete a Valkey instance high
databases.extension.list List PostgreSQL extensions (read) low No dry run
databases.extension.set Turn a PostgreSQL extension on or off medium
databases.engine.timezone.get Show the MySQL time zone (read) low No dry run
databases.engine.timezone.set Set the MySQL time zone medium
databases.valkey.adopt Take over a Valkey container made by hand high
databases.valkey.import Import data into a Valkey instance high
databases.valkey.old.list Show the old containers left after a take-over (read) low No dry run
databases.valkey.old.remove Remove an old container left after a take-over medium
databases.server.create Register an external database server medium
databases.server.list List external database servers (read) low No dry run
databases.server.get Get an external database server (read) low No dry run
databases.server.update Change an external database server medium
databases.server.test Test an external database server low No dry run
databases.server.delete Remove an external database server high
databases.db.snippets Connection snippets (read) low No dry run
databases.connection.for_node Connection for a web server (read) low No dry run
databases.admin.open Open the database tool medium
databases.admin.session.list Open database tool sessions (read) low No dry run
databases.admin.close Close a database tool session low
databases.reconcile Re-apply all databases medium
databases.config.reset_all Reset the whole service to defaults high
databases.config.snapshot.list Snapshots before resets (read) low No dry run
databases.config.snapshot.restore Undo a reset (restore a snapshot) high
databases.config.history.list Earlier versions of a file (read) low No dry run
databases.config.history.diff Compare an earlier version (read) low No dry run
databases.config.history.restore Restore an earlier version of a file high
databases.unmanaged.scan Scan now for objects made outside the panel low No dry run
databases.unmanaged.list Objects made outside the panel (read) low No dry run
databases.unmanaged.ignore Ignore or un-ignore an unmanaged object low
databases.unmanaged.adopt Adopt an object made outside the panel medium
databases.unmanaged.remove Remove an object made outside the panel high
databases.config.status Hand-edited database server files (read) low No dry run
databases.config.adopt Keep a hand edit of a database server file medium
databases.config.reapply Render a database server file again high
databases.config.unmanage Hand a database server file off to the administrator high

Permissions and limits

Permissions

  • databases.db.view View databases, users and instances
  • databases.db.manage Create and delete databases
  • databases.user.manage Manage database users and passwords
  • databases.grant.manage Change database grants
  • databases.remote.manage Allow remote connections
  • databases.export.run Export (dump) databases
  • databases.import.run Import (restore) databases
  • databases.query.run Run statements in the query console
  • databases.valkey.manage Manage Valkey instances
  • databases.engine.manage Install database engines on servers
  • databases.reconcile Re-apply every database to its server
  • databases.server.view View external database servers
  • databases.server.manage Register and change external database servers
  • databases.admin.open Open the database tool

Plan limits

  • databases.count Databases
  • databases.users Database users
  • databases.size_mb Total database size
  • databases.connections Connections per database user
  • databases.statement_timeout_s Longest database statement (0 = no limit)
  • databases.remote_hosts Remote host rules
  • databases.valkey_instances Valkey instances
  • databases.valkey_mb Valkey memory (all instances)
  • databases.servers_sql External MySQL/MariaDB/PostgreSQL servers (0 = not allowed)
  • databases.servers_clickhouse External ClickHouse servers (0 = not allowed)
  • databases.servers_redis External Redis/Valkey servers (0 = not allowed)
  • databases.servers_mongodb External MongoDB servers (0 = not allowed)

Engineering notes

Generated from modules/databases/docs.md at build 38156245. These are the notes the engineers keep next to the code: precise, technical, and honest about what is not done yet.

Customer database servers are installed on the node by the driver (internal/agent/databases*.go); the panel's own Postgres is unrelated. Listeners are loopback-only until some user has remote hosts.

Model

  • Names are <account>_<name> (account - becomes _); database <= 48, user <= 32 characters.
  • Privileges (readonly / readwrite / admin) replace each other on databases.grant.set. MariaDB: SELECT / DML / ALL on `acct\_db`.* (underscore escaped; no GRANT OPTION). PostgreSQL: per database three NOLOGIN group roles <db>_own (owner; admin users are members and log in with SET ROLE, so what they create is owned by the group), <db>_rw, <db>_ro, plus default privileges for new tables.
  • Passwords are generated (24 chars), returned once by create/reset, never stored, never in list/get. With store_in_vault the vault keeps it and databases.user.password.reveal returns it (audited). Supplied passwords: 12-128 chars, letters+digits, no quotes/backslash/space/backtick. Top-level password keys are redacted by the host audit.
  • Remote access (databases.remote.set): IPv4/IPv6 addresses or IPv4 CIDR; %//0 and ranges wider than /16 admin-only. MariaDB: extra 'user'@'host' entries (CIDR becomes addr/netmask) + REQUIRE SSL; PostgreSQL: hostssl/host lines in rc-hba.d/<user>.conf (included from pg_hba.conf, PG 16+). The engine listens on 0.0.0.0 only while some user has remote hosts (restart on change). TLS uses a self-signed cert generated by the agent (ssl module cert later). The firewall rule belongs to the security module (not built): the plan warns about it.
  • Limits: databases.count/users/valkey_instances/valkey_mb/remote_hosts Reserve/Release; databases.connections becomes MAX_USER_CONNECTIONS / role CONNECTION LIMIT (read from the plan by probing Reserve, see follow-ups); databases.size_mb is enforced by databases.db.stats (reserves growth; when refused the database's grants are forced read-only, restored when it fits again; status quota_exceeded).
  • Dump/restore: databases.db.export writes .sql/.sql.gz into the account's home, databases.db.import reads it. All file access runs as the account via runuser (no symlink escape by a root agent). Import runs as an ephemeral user with rights on that database only (cannot CREATE USER / touch other DBs; verified).
  • Valkey: rc-valkey@<account>_<name> from a template unit, User=<account>, Slice=rc-acct-<account>.slice, loopback port from a sequence + unix socket in ~/valkey/<name>/, user default off, ACL user with a sha256 hash (no clear password on disk), dangerous commands denied, maxmemory from the request (counted against databases.valkey_mb), MemoryMax = 2x+64M. An rc-agent ACL user (token only in /etc/rc-valkey) feeds stats.
  • Desired state first, then apply (idempotent); databases.reconcile re-applies everything keeping passwords; accounts.deleted subscription removes everything of the account (durable, idempotent).

Verified in the lab (2026-10-09, Ubuntu 24.04: MariaDB 10.11, PostgreSQL 16, Valkey 7.2)

  • Create db+user on both engines; connect from a second container over TLS with the generated password; wrong password refused; before remote.set the port is closed; with require_tls a non-TLS client is refused (both engines).
  • databases.count limit 2: third create -> limit_exceeded; valkey instance limit likewise; connection limit 3: fourth concurrent session -> max_user_connections error.
  • readonly user cannot INSERT; readwrite can, cannot CREATE; password reset invalidates the old one; vault reveal.
  • Export -> drop table -> import restores rows on both engines (gz and plain), ephemeral roles gone; a dump with CREATE USER is refused; ../ paths refused.
  • Size quota flips a PostgreSQL database read-only (an empty PG database is ~7 MB).
  • Reconcile recreated a database and user dropped behind the panel's back; remote off closes the listener again; Valkey runs as the account in its slice, CONFIG is denied; account deletion removed DBs/users/roles via the event.

External (bring-your-own) servers — w6-04

  • databases.server.create registers a MySQL/MariaDB, PostgreSQL, MongoDB, Redis/Valkey or ClickHouse server: host, port, tls (off | on = encrypted, certificate not checked | verify = checked, optionally against a pasted CA) and the admin login. It is TESTED ON SAVE through the account's node (databases.server.test agent op: version, encryption, latency); a failing test saves nothing. The admin password goes to the vault (server/<id>) and is never returned, logged, audited or put in an event; it reaches the client only in its environment (MYSQL_PWD, PGPASSWORD, an HTTP header, RESP AUTH), never argv or SQL (unit-tested).
  • Plans: limits databases.servers_sql / _clickhouse / _redis / _mongodb (count; 0 = that kind is not allowed).
  • Every existing action takes server_id (db.create, user.create, lists); the engine is the server's kind. Names keep the <account>_ prefix. Users on an external MySQL/MariaDB get host % unless remote.set restricts them. Per kind: MySQL/MariaDB (flavour auto-detected: MySQL 8 copies hashes as IDENTIFIED WITH plugin AS 0x..) and PostgreSQL (same <db>_own/_rw/_ro model; a newer server brings the matching PGDG pg_dump) support everything incl. export/import/size; ClickHouse (HTTP interface: databases, SQL users, GRANT on db.*, sizes) has no export/import; Redis/Valkey: a "database" is the key namespace <name>:*, users are ACL users, readonly = %R~; MongoDB: register + connectivity test only (management is a follow-up). The agent refuses loopback / link-local / metadata hosts and names resolving to them (use the built-in engine for this node).
  • Deleting a server is refused while databases/users are registered on it; deleting an account forgets its servers (the servers themselves are never touched).
  • databases.db.snippets: PHP, Node, Python, Go, Ruby, Java and .NET for every family, with a PASSWORD placeholder.

Built-in engines on demand (databases.engine.install)

mysql (Oracle 8.4 LTS apt repo; refused while MariaDB owns :3306), postgresql + version 14-18 (PGDG), clickhouse (vendor repo; loopback; the passwordless default user is removed, rc_admin credentials in /etc/rc-clickhouse/admin.json 0600), qdrant (pinned release + SHA-256, loopback, API key in /etc/rc-qdrant/env), ferretdb (v1.24 pinned, over the node's PostgreSQL: a FerretDB "database" is a PostgreSQL database + user, clients use the PostgreSQL login with authMechanism=PLAIN). Repos and download URLs are fixed in databases_engines.go; keys are fetched over https.

Database tool (Adminer) - w11-61, proven and ON by default in w11-85

databases.admin.open (one database + one of its users) -> a single-use ticket -> the editor gateway's isolated origin -> Adminer 6.1.1 (pinned in the version catalogue, sha256-checked) running as the ACCOUNT's own user in its slice with no network, behind a root-owned socket. PHP is the node's own php-cli (the web server install brings it; the first open adds the PostgreSQL driver through apt once). The login is ephemeral, has the chosen user's privilege only and is never shown, stored or audited. Sessions are listed on the database's "Database tool" tab with Close; a session ends with the panel session, after 30 minutes without use, at the end of its life (admin_tool_session_hours, 4) or when its link was never opened. Built-in MariaDB, MySQL and PostgreSQL databases only; opens in its own tab (not framed), not made for a phone. Setting admin_tool_enabled (default on) switches it off for the whole server and closes every open session at the next sweep. Proof, limits and the bugs the real sign-in found: docs/security/database-tool.md; the lab walk is lab/tests/database-tool.sh.

Follow-ups closed

import takes clean (drops everything first: MariaDB/MySQL drop+create keeping charset, PostgreSQL recreates public); size enforcement runs from the schedule databases.stats.run (15 min, one unreachable server does not stop the rest).

Next

UI (w6-08); panel reverse proxy for the admin tool; MongoDB management on external servers; Qdrant collections/keys per account; ClickHouse/Redis dump; pin repo key fingerprints; grace period for deletes (AC-18), clone/rename, maintenance ops, slow-query log; firewall rule via security.

Several web servers (w11-177)

A database lives on one server. A pooled PHP site on other web servers must write to it there: 127.0.0.1 on those servers is their own (read-only replica or empty) engine. With replication set up, the cluster module publishes db-primary.rc.internal (the first pair's primary) and db-primary-<engine>.rc.internal (each engine's primary) in /etc/hosts on every node and moves them on a promotion. databases.connection.for_node and the snippets answer (multi_node_host) say which name to use; customer-uploaded PHP sites should put that name in their config. When a pool's servers change, databases.pool.grant opens the account's built-in database users to every web server of the pool. The firewall rule for the database port is still the security module's.

Moving real databases onto a server (w12 card B)

  • Import (databases.db.import, a job with progress; a log file is kept in the account's home under backups/databases/import-<db>-<time>.log).
    • PostgreSQL reads the kind from the file: custom (pg_dump -Fc) and directory (-Fd) dumps go through pg_restore (jobs loads tables in parallel), plain .sql and .sql.gz through psql. Both run as the account, logged in as an ephemeral role that runs as the database's own role <db>_own, so everything the dump creates belongs to it and not to postgres (that role is also what the app's login runs as; see Model). no_owner (default true) drops owners and privileges of the dump (pg_restore --no-owner --no-acl; for plain dumps single-line ALTER ... OWNER TO, GRANT and REVOKE lines outside COPY data are skipped). clean drops every schema first. exclude_tables leaves tables out with their indexes, keys, defaults, triggers, sequences and the foreign keys others have to them (custom/directory dumps only); data_only / schema_only likewise.
    • Extensions the dump needs are created first as the server's administrator (the restoring role is no superuser), after installing the OS package if the server lacks it.
    • The client's output is sorted: report.errors are things that did not load (the action then fails with them listed, and the data that did load stays); report.notes are PostgreSQL's harmless "must be owner of extension" and "schema public already exists". report.log_file is the whole output.
    • MySQL and MariaDB: .sql or .sql.gz, as before. The MySQL 9 client has no --skip-ssl: external servers now get --ssl-mode= for it.
  • Extensions (databases.extension.list / .set, PostgreSQL built-in only): vector (pgvector), pg_trgm, btree_gist, pg_stat_statements, citext, unaccent, uuid-ossp, postgis (when the package exists). set installs the package from the agent's allow-list (postgresql-<major>-pgvector, postgresql-<major>-postgis-3; RHEL: pgvector_<major>), creates or drops the extension, and for pg_stat_statements writes shared_preload_libraries into conf.d/97-respirecloud-preload.conf, restarts PostgreSQL once and creates it in postgres too (where the slow-statement list reads it). The preview lists those steps.
  • Exact names (exact: true on db.create, user.create, valkey.create; administrators only): nerix_db is nerix_db, not <account>_nerix_db. An exact name is outside every account's name space; customers keep the prefix rule.
  • Given passwords for moves: password or password_hash as before, or password_file: a file in the account's home with the password on one line, read by the agent as the account. Through the CLI that is the way to keep a password off the command line (and -f - takes the whole JSON, password included, from stdin).
  • MySQL time zone (databases.engine.timezone.get / .set): default_time_zone as an offset (+04:30), UTC, SYSTEM or a name (Asia/Kabul; the zone tables are loaded when needed). A managed file 98-respirecloud-timezone.cnf keeps it across restarts, SET GLOBAL applies it to new connections at once. TIMESTAMP values are stored in UTC and shown in the zone; DATETIME values are never converted. Charset and collation are per database at creation (db.create --charset --collation, e.g. utf8mb4 / utf8mb4_0900_ai_ci).
  • Valkey as a container (runtime: container on valkey.create; ADR 0033): docker run by the agent with every capability dropped, user 999:999, no-new-privileges, read-only root, a pids and memory limit, published on 127.0.0.1:<port> (port chosen or the next free one). The password is the password of the default user (as requirepass, kept as a sha256 ACL hash in /etc/rc-valkey/<name>.conf, owned by the container's user, mode 0400); dangerous commands are denied. maxmemory, eviction policy and none/rdb/aof persistence as before. Data lives in the Docker volume rc-valkey-<name>. The default image is pinned by digest in internal/agent/databases_valkey_ctr.go.
    • databases.valkey.adopt takes over a container made by hand (nerix-valkey): same port, same volume (no copy), the password you give; the old container is stopped and kept as <name>-replaced, and started again if the managed one does not come up.
    • databases.valkey.import replaces an instance's data with an .rdb, .rdb.gz, .tar or .tar.gz of a data folder. An RDB loaded into an instance that keeps an AOF is converted first (a server that finds only an RDB with appendonly yes starts empty; verified).
    • Process instances (systemd, in the account's slice) are unchanged and still the default.
  • Batch fix (walk data, 2026-10-27):
    • extension.set needs no id: left out, it works in any PostgreSQL database of the built-in server (the slow-statements "Turn it on").
    • A plain pg_dump import also skips ALTER DEFAULT PRIVILEGES; a MySQL or MariaDB import drops SQL_LOG_BIN and GTID_PURGED lines (a stock mysqldump from a GTID server needs SUPER for them and they change no data).
    • databases.db.delete previews without the typed name, and with_users also removes the login users that belong to that database only (the screen offers it, on). Without it the result names the users it kept.
    • A password the caller gave (password, password_file) is never printed back.
    • Previews of create and adopt check the plan limits the real call will meet. Create and import read the size at once.
    • databases.valkey.old.list / .remove: the stopped ...-replaced container an adopt keeps, with a "Remove the old container" button.
    • The new-Valkey dialog has port, password, "Runs as" and "Take over a container that already runs"; Engines does not offer to install the Valkey package on a node that runs container instances.
    • Engine install makes /run/mysqld exist at every start (MariaDB 13 on Ubuntu 26.04 did not start without it).
    • The CLI's --file is the JSON-input option only for actions that have no file parameter (-f always is).
  • Screens: Engines lists MariaDB, MySQL (not beside MariaDB, said in words), PostgreSQL and Valkey, with the MySQL time zone under an installed MySQL or MariaDB; a PostgreSQL database has an Extensions tab; Import has "Show details" for the options above; a container Valkey has "Import data".
  • Previews: every change in this module has dry_run (import, export, password set, Valkey reset, extension, time zone, adopt and the Valkey import included).

Other servers, found on the server, extension schema

  • Databases > "Other servers": register, check and remove external database servers (the admin password goes to the vault).
  • Databases > "Found on the server" (administrators): databases and logins made by hand; pick the account, then Adopt, Hide or Remove (a copy is saved first).
  • A password given with no user name is refused ("no user would be created"). A password file whose content has spaces, quotes or backslashes is refused before the database is made. Nothing reports success while skipping the user.
  • databases.extension.set takes schema: the extension is created there (the schema is made if missing); one already installed is moved.

Valkey without the Valkey package, and password files (w14)

  • databases.valkey.create with no runtime runs the instance as a container when this server has no Valkey package; asking for runtime: process there still refuses, and the message names the container runtime as the other way.
  • password_file may be a path relative to the account's home or an absolute path inside /home/<account>/. Any other path is refused in the preview with the reason, so a preview that passes also applies.

Screens in the 1.0.15 round

  • Connect tab: shows the full login user (matched from databases.user.list on the database's first access), copy buttons for host, port, database and user, and "Make a new password" (databases.user.password.set); the new password shows once. The button needs databases.user.manage. The code snippets still use a $PASSWORD placeholder.
  • Cache naming: Valkey is called "Cache (Valkey)" in the engine filter, the create text and the list.
  • One container form (Stacks, in the containers module): the default source; image, port, name (from the image), optional data folder (a named volume, never a host folder), variables, address step, Compose preview behind "Show details".
  • Open row: one level of navigation. Opening a database shows how to connect, then collapsed sections (Users and access, Backups, Import and export, Extensions for PostgreSQL, Query, Database tool, Maintenance); each remembers whether it was left open.