---
title: "Users and logical databases"
description: "Create logical databases and users with a preset from the console or CLI, with each user's password kept in a Secret for your app to read."
---

> 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.

# Users and logical databases

Inside a database you can create **logical databases**, such as `shop` for an app, and **users** with a
preset on one of them. EZGH generates each user's password and keeps it in a [Secret](/secrets) in the
database's project, ready for your app to read. You don't connect to the database to do any of it.

## Presets

A user has one preset on one logical database. It grants nothing in any other logical database.

| Preset | Can |
| --- | --- |
| `readOnly` | Read every table, view and sequence, including ones created later. |
| `readWrite` | Everything `readOnly` can, plus insert, update and delete rows, use sequences and create temporary tables. |
| `owner` | Everything in the logical database: create, change and drop schemas, tables and other objects. |

On Percona Server and MariaDB the presets are grants on the whole logical database (`` `shop`.* ``):
`readOnly` is `SELECT, SHOW VIEW`; `readWrite` adds `INSERT, UPDATE, DELETE, EXECUTE, CREATE TEMPORARY
TABLES, LOCK TABLES`; `owner` is `ALL PRIVILEGES` without `GRANT OPTION`.

A user's preset can be changed later. Its logical database can't: delete the user and create another.

## Create a logical database and a user

### Console

1. Open **Databases**, then the database, then its **Logical databases** tab, and choose **Create
logical database**. Enter a name, review, then choose **Create logical database**.
2. On its **Users** tab, choose **Create user**. Enter a name, pick the logical database and a preset
(**Read only**, **Read and write** or **Owner**), review, then choose **Create user**.
3. The user's row links to its Secret.
### CLI

```sh
ezgh databases logical-databases create dbi_4k2m9x0a7qpe shop --wait
ezgh databases users create dbi_4k2m9x0a7qpe shop_app --logical-database shop --preset readWrite --wait
ezgh databases users get dbi_4k2m9x0a7qpe shop_app
```

```txt
Name:              shop_app
Database:          dbi_4k2m9x0a7qpe
Managed:           yes
Preset:            readWrite
Logical database:  shop
Status:            available
Secret:            sec_u1v2w3x4y5z6
URI:               ezgh secrets read sec_u1v2w3x4y5z6 --project 0199a3c2-6c2f-7e51-8a4b-3d9f7c2e5a81 --field uri --format raw
Checked:           2026-11-03T10:00:00.000Z
Created:           2026-11-03T10:00:00.000Z
```

`ezgh databases users update … --preset readOnly` changes the preset, `rotate-password` writes a new
password, and `delete` deletes the user.

In the API, [CreateLogicalDatabase](/databases-api/CreateLogicalDatabase/) and
[CreateDatabaseUser](/databases-api/CreateDatabaseUser/) answer `202` with an operation. The logical database or user exists from then on, `creating`, and a
user's `secret` is set.

Creating a user writes its Secret as you, so it also needs `secrets.secrets.create` and
`secrets.versions.create` in the project.

Names are 1–32 characters for users and 1–63 for logical databases: lowercase letters, digits and
underscores, starting with a letter. Names starting `ezgh_` or `pg_`, and the engines' own names such
as `postgres`, `mysql`, `root`, `sys` and `public`, are reserved.

## Read the credential in your app

The user's Secret, named `databases/<database>/users/<user>`, has the fields `username`, `password`,
`host`, `port`, `database` (the logical database), `engine` and `uri`. `uri` is a connection URI that
verifies the server:

```txt
postgresql://shop_app:…@db-hylq6kelvuwvn2ks4yqhp4jaqu.us-west-1.ezghcompute.com:5432/shop?sslmode=verify-full
mysql://shop_app:…@db-hylq6kelvuwvn2ks4yqhp4jaqu.us-west-1.ezghcompute.com:3306/shop?ssl-mode=VERIFY_IDENTITY
```

On Percona Server and MariaDB, and with JDBC drivers, most clients don't take this URI: connect with the
`host`, `port`, `username`, `password` and `database` fields instead.

Read a field with your app's access to Secrets, for example:

```sh
DATABASE_URL="$(ezgh secrets read sec_u1v2w3x4y5z6 --project 0199a3c2-6c2f-7e51-8a4b-3d9f7c2e5a81 --field uri --format raw)"
```

The client trusts the EZGH CA bundle, `https://get.ezghcloud.com/databases/ca-bundle.pem`, as for the
admin user ([TLS](/databases/connecting#tls)):

### PostgreSQL

libpq and drivers built on it take the bundle as `sslrootcert`, added to the URI or set as
`PGSSLROOTCERT=ca-bundle.pem`. The PostgreSQL JDBC driver takes `sslrootcert` as a URL parameter.
### Percona Server

MySQL clients take the bundle as `--ssl-ca=ca-bundle.pem`. In MySQL Connector/J, `sslMode=VERIFY_IDENTITY`
with the bundle as the trusted CA. In Go's `go-sql-driver/mysql`, a `tls.Config` with the bundle as
`RootCAs` and the host as `ServerName`, registered with `mysql.RegisterTLSConfig`.
### MariaDB

The MariaDB client takes `--ssl-verify-server-cert --ssl-ca=ca-bundle.pem`. MariaDB Connector/J takes
`sslMode=verify-full` and `serverSslCert=ca-bundle.pem`.

Rotating a user's password writes a new version of its Secret. New connections need it, and open ones
carry on. If you deleted the Secret, rotating writes a new one. Rotating needs `secrets.versions.create`,
and `secrets.secrets.create` when it writes a new Secret. A rotation that a newer rotation replaced is
refused with `409`; use the newest rotation's password.

## Changes made in SQL

Logical databases and users made in SQL show in the lists, marked **Made in SQL** in the console and
`no (made in SQL)` by the CLI. They can't be changed or deleted through EZGH. You can create a user on a
logical database made in SQL.

Changes you make in SQL to users and logical databases created through EZGH are kept until your next
change to them through EZGH, such as a new preset or a password rotation, which applies the preset again. One that's dropped in SQL shows as `missing`. Rotating a missing user's password creates it
again with its preset, and creating a missing logical database makes it again.

The lists come from the database and update within a minute of a change made in SQL. The console shows
when they were last checked.

### PostgreSQL

- `owner` needs a logical database created through EZGH. On one made in SQL, `readOnly` and `readWrite`
  work.
- Tables an `owner` user creates are covered by the other presets. Tables created by roles made in SQL
  aren't: create tables as an `owner` user, or grant on them yourself.

## Delete

A logical database or user whose create failed shows as `failed`, with the reason. Delete it and create it again.

Deleting a logical database deletes its data. It's refused while users created through EZGH use it.

Deleting a user deletes its Secret straight away, then the user. Tables it created stay. It needs
`secrets.secrets.delete` in the project too. On Percona Server, deleting a user that's the definer of a
view or stored routine is refused; the user stays with its preset and no Secret. Change the
definer, then delete it again, or rotate its password to get a new Secret. The user shows the reason the
delete was refused.

## Limits

| Limit | Default |
| --- | --- |
| Logical databases created through EZGH, per database | 100 |
| Users created through EZGH, per database | 100 |

You can ask for more in [Service quotas](/quotas).

While a database is being created, upgraded or deleted, has failed, is rotating its admin password, or
has a blue/green deployment open, creating, changing and deleting its users and logical databases is refused (`409 database_busy`,
`409 blue_green_in_progress`). A database that doesn't support users yet refuses them with
`409 users_unavailable` until its next maintenance update.

Source: https://docs.ezghcloud.com/databases/users-and-logical-databases/index.mdx
