---
title: "Databases"
description: "Managed PostgreSQL, Percona Server and MariaDB databases in your VPC, with backups, point-in-time restore, blue/green upgrades and metrics in Obs."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Databases

EZGH Databases runs PostgreSQL, Percona Server for MySQL and MariaDB for you, in a subnet of your
VPC. You connect to an **endpoint**, a DNS name that stays the same for the database's life. If the
database fails, it fails over by itself, the endpoint follows, and clients reconnect to the same name.

- [Connecting](/databases/connecting) — The endpoint, the admin password, TLS and client settings.
- [Connect without entering your VPC](/databases/connect-without-vpc) — ezgh databases connect from a laptop, and Query in the console.
- [Users and logical databases](/databases/users-and-logical-databases) — Logical databases, and users with a preset and their password in a Secret.
- [Engines and versions](/databases/engines-and-versions) — Engines, versions, instance types, storage and parameters.
- [Plugins](/databases/plugins) — PostgreSQL extensions, MySQL-family plugins and the admin user's privileges.
- [Backups and restore](/databases/backups-and-restore) — Automated and manual backups, and restores to any second.
- [Blue/green deployments](/databases/blue-green) — Upgrade to a new major version, tested before you switch.
- [Monitoring](/databases/monitoring) — Engine metrics, dashboards, Insights and logs in Obs.
- [Firewalls and subnets](/databases/firewalls-and-subnets) — Who may connect, firewall rules that name a database, and subnet room.

The Databases API is at `https://databases-api.ezghcloud.com`. In the console, open **Databases**.

## Before you start

A database needs a [subnet](/private-networks/vpcs) of a VPC with at least **16 free addresses**.
It's reached only from inside the VPC: there's no public address.

The admin password goes to a new [Secret](/secrets) in the project, written as you, so creating a
database also needs `secrets.secrets.create` in the project.

## Create a database

1. List the engines and versions:

   ```sh
   ezgh databases engine-versions
   ```

2. Create the database. This takes minutes, and `--wait` waits until it's available:

   ```sh
   ezgh databases create orders --engine postgresql --engine-version 18 \
     --instance-type gp-1.large --subnet sbn_2m9x0a7qpe4k --storage-size-gib 100 --wait
   ```

3. Show how to connect:

   ```sh
   ezgh databases connection dbi_4k2m9x0a7qpe
   ```

In the API, [CreateDatabase](/databases-api/CreateDatabase/) answers `202` with an operation.
The database exists from then on, `creating`, with its ID. Its `endpoint` is `null` until the name
resolves. If a create fails, its admin Secret stays in the project: delete it yourself.

## Status

| Status | Means |
| --- | --- |
| `creating` | It's being created. |
| `available` | It's serving. |
| `modifying` | A change is being applied. It serves meanwhile. |
| `failing_over` | It's failing over. Open connections end, and clients reconnect to the same endpoint. |
| `recovering` | It failed over and is finishing recovery. It serves meanwhile. |
| `upgrading` | Maintenance is being applied. It serves meanwhile. |
| `storage_full` | Its storage is full and writes fail. [Grow the storage](/databases/engines-and-versions#storage). |
| `deleting` | It's being deleted. |
| `deleted` | It's gone. |
| `failed` | It couldn't be created. |

New statuses may appear. A database's **Events** list (`ezgh databases events`) records its failovers
and recoveries, maintenance, blue/green switchovers and failures, backups, and full storage.

## Maintenance

Engine minor versions and other updates are applied automatically in the database's maintenance
window, with one brief failover: open connections end, and clients reconnect to the same endpoint.
Maintenance that can't wait may be applied outside the window, and is listed in the database's
events.
The window is `ddd:HH:MM-ddd:HH:MM` in UTC, at least 30 minutes, for example `sun:04:00-sun:04:30`.
Each database gets a default window, which you can change:

```sh
ezgh databases update dbi_4k2m9x0a7qpe --maintenance-window sun:04:00-sun:04:30
```

Changes you make yourself, such as a new instance type, apply when you make them.

You can also fail a database over yourself, for example to test how your app reconnects:

```sh
ezgh databases failover dbi_4k2m9x0a7qpe --wait
```

It's refused with `409 not_eligible` when the database can't fail over right now: try again in a few
minutes.

## Delete a database

```sh
ezgh databases delete dbi_4k2m9x0a7qpe --wait
```

A final backup is taken first, unless you pass `--final-backup=false` (`?finalBackup=false` in the
API) or the database never became available, and it's kept like a
[manual backup](/databases/backups-and-restore#manual-and-final-backups).
Automated backups go with the database. The admin Secret stays in the project.

The delete is refused with `409 deletion_protected` while deletion protection is on
(`deletionProtection`; `--deletion-protection` and `--deletion-protection=false` on create and
update), and with
`409 database_in_use` while a [firewall rule](/databases/firewalls-and-subnets#firewall-rules) names
the database, and with `409 deployment_switching_over` during a
[blue/green switchover](/databases/blue-green): wait for it to finish.

## Pricing

A database runs on a pair of nodes of its instance type. It's billed by the hour at twice the hourly
price of an instance of that type, and a [blue/green deployment's](/databases/blue-green) green is
billed the same way while it exists. Storage and backups aren't billed yet. See
[Pricing](/billing/pricing) for current prices.

## Refusals

| Refusal | Means |
| --- | --- |
| `409 database_not_available` | The database can't take this in its current status, for example `creating` or `failing_over`. |
| `409 operation_in_progress` | Another change, failover or password rotation is running. Wait for its operation. |
| `409 blue_green_in_progress` | A [blue/green deployment](/databases/blue-green#while-its-open) is open. |
| `409 not_eligible` | The database can't fail over right now. |
| `409 deletion_protected` | Deletion protection is on. |
| `409 database_in_use` | A firewall rule names the database. |
| `409 subnet_has_no_room` | The subnet is out of free addresses. |
| `409 database_busy` | The database can't change its users or logical databases in its current status, or while its admin password is being rotated. |
| `409 users_unavailable` | The database supports users and logical databases after its next maintenance update. |
| `409 unmanaged` | The user or logical database was made in SQL. Change it in SQL. |
| `409 logical_database_in_use` | Users created through EZGH are on the logical database. Delete them first. |
| `409 logical_database_not_available` | The logical database isn't `available`: for example, it's being created, has failed or is missing. |
| `409 owner_needs_managed_logical_database` | On PostgreSQL, `owner` needs a logical database created through EZGH. |

## Limits

| Limit | Value |
| --- | --- |
| Databases per project | 5 by default, up to 40 |
| Manual backups per database | 50 by default, up to 500 |
| Allowed sources per database | 20 |

## IAM

| Policy | Allows |
| --- | --- |
| `DatabasesFullAccess` | Everything here. |
| `DatabasesReadOnlyAccess` | Listing and viewing databases, backups, blue/green deployments, logical databases and users. `ReadOnlyAccess` includes the same. |

A restore also needs `databases.backups.get` on its source. Rotating the admin password writes a new
version of the Secret as you, so it also needs `secrets.versions.create`. Creating a blue/green
deployment also needs `databases.databases.update` on the database.

Source: https://docs.ezghcloud.com/databases/index.mdx
