Databases
ZoCloud offers three kinds of managed database:
| On the portal | Engine | Main variable |
|---|---|---|
| PostgreSQL | PostgreSQL | DATABASE_URL |
| MySQL (MariaDB) | MariaDB, MySQL-compatible | DATABASE_URL |
| Redis (Valkey) | Valkey, Redis-compatible | REDIS_URL |
Databases run on ZoCloud's private network, are reachable only by the apps in the same environment, and are backed up every night and encrypted. A database's storage and RAM are shown at the top of its page.
MongoDB is not available yet.
Creating a database
- On the project canvas, click Add → choose the engine under Database.
- Enter a Name (lower-case letters, digits,
-). The name is used in reference variables, for example${{pg.DATABASE_URL}}. - Click Create. The database is ready within seconds.
CLI: zo db create pg -engine postgres (or mysql, valkey).
Connecting from a service
The database's Connect tab shows the reference variables to use. Add them to the service's Variables and redeploy:
DATABASE_URL=${{pg.DATABASE_URL}}
REDIS_URL=${{cache.REDIS_URL}}
The values update on their own if the database moves to another server or its password changes.
Available variables
| Engine | Variables |
|---|---|
| PostgreSQL | DATABASE_URL (through the connection pool, transaction mode), DATABASE_URL_DIRECT (a direct connection: use it for migrations, LISTEN/NOTIFY, advisory locks and session-level SET; Prisma: set it as directUrl), PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE, and DATABASE_PUBLIC_URL when Internet access is on |
| MySQL (MariaDB) | DATABASE_URL, MYSQL_URL, MYSQLHOST, MYSQLPORT, MYSQLUSER, MYSQLPASSWORD, MYSQLDATABASE, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD (Laravel style), and DATABASE_PUBLIC_URL |
| Redis (Valkey) | REDIS_URL, VALKEY_URL, REDISHOST, REDISPORT, REDISUSER, REDISPASSWORD |
Connection variables → Show connection details reveals the full values (password included), and only when you click it. CLI: zo db vars pg.
Internet access (TLS)
Use this when you need to connect from your own computer (TablePlus, DBeaver, running migrations). PostgreSQL and MySQL only; Valkey cannot be opened to the outside.
- Connect tab → Internet access → turn it on and confirm Open it.
- The portal shows
host:port(of the formtcp.zocloud.app:30xxx). The full connection string is in theDATABASE_PUBLIC_URLvariable under Connection variables. - The connection requires TLS: PostgreSQL uses
sslmode=require, MySQL usesssl-mode=REQUIRED(already included in the string).
psql "$(zo db vars pg | grep ^DATABASE_PUBLIC_URL= | cut -d= -f2-)"
Anyone with the password can connect from anywhere: turn it off when not in use. CLI/MCP: the database_public tool.
Backup and restore
The Backups tab:
- Automatic backups every night, encrypted, with the primary copy kept in Vietnam and retained according to ZoCloud's retention policy.
- Back up now takes a manual backup, for example before running a large write.
A restore always goes into a new database; the current one keeps running:
- Enter the new database's name in the box above the list.
- Pick a backup → Restore. The portal shows "Restoring into …".
- Check the data in the new database.
- Switch the service's variable to
${{<new-name>.DATABASE_URL}}and redeploy.
Browsing data (the Data tab)
For PostgreSQL and MySQL. For Valkey, use valkey-cli or redis-cli with the connection details.
- Tables: pick a table (filter with Find a table) to page through its data.
- SQL: type a query and click Run. Results are limited to a number of rows; if you see "more rows not shown", add a
LIMITor narrow the query. Each query has a time limit. - The Read only switch is on by default. Turn it off to run write statements (
INSERT,UPDATE,DELETE,ALTER…). Writes change the data immediately and cannot be undone: take a backup first.
Queries run as the database's own account; results are not stored, but every run is recorded in the organisation's Activity.
| Role | Browse tables, run read-only SQL | Run writes |
|---|---|---|
| Owner, Admin | yes | yes |
| Developer | yes | no |
| Billing, Viewer | no | no |
Storage
Each database has a disk allowance (shown at the top of the page, for example "Storage 120 / 5120 MB"), measured about every 10 minutes. ZoCloud suggests action when a database uses more than about 85% of its allowance. The number of databases is a limit of your plan.
Deleting a database
Settings tab → Delete database, type the name to confirm. The database and all its data are deleted; backups are kept according to the retention policy.
PostgreSQL connection pool
PostgreSQL's DATABASE_URL goes through PgBouncer in transaction mode: each app can open many connections while the server keeps only a few real ones per database, so several apps on the same machine do not starve each other. Most ORMs work as usual (prepared statements are supported). Anything that needs one continuous session should use DATABASE_URL_DIRECT: running migrations (Prisma directUrl, Rails db:migrate), LISTEN/NOTIFY, advisory locks, session SET variables, WITH HOLD cursors.