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

# Manage databases from the CLI

> Create, inspect, resize, start, stop and delete Square Cloud databases with squarecloud db, and print or rotate their TLS certificate and password.

`squarecloud db` manages the MongoDB, MySQL, PostgreSQL and Redis databases of your account. It also works as `squarecloud database`.

Databases have no configuration file, so `[dbID]` is either the ID you pass or, when you omit it in a terminal, a picker of your databases. Find IDs with [`squarecloud db list`](#squarecloud-db-list).

## `squarecloud db create`

```bash Usage theme={"system"}
squarecloud db create --name <name> --memory <MB> --type <engine> --version <version> [--json]
```

| Flag | Description |
| - | - |
| `--name <name>` | Database name, 1 to 32 characters. |
| `--memory <MB>` | Allocated memory in MB. |
| `--type <engine>` | `mongo`, `mysql`, `redis` or `postgres`. |
| `--version <version>` | Engine version: a major version, such as `17` for PostgreSQL or `8` for MongoDB, or a full version. |

All four flags are required: without them, the command prints its help. Creating a database needs a Standard, Pro or Enterprise plan.

```bash theme={"system"}
squarecloud db create --name my-db --memory 1024 --type postgres --version 17
```

```bash Output theme={"system"}
✓ Database my-db (<dbID>) created successfully
Save the password now: it is shown only once and cannot be recovered.
  PASSWORD: <password>
  URL: <connection URL>
```

<Warning>
  The password is shown only once. `db info` doesn't show it again; if you lose it, rotate it with [`db credentials reset password`](#squarecloud-db-credentials-reset).
</Warning>

With `--json`, it prints the created database, password and connection URL included, as JSON.

## `squarecloud db list`

```bash Usage theme={"system"}
squarecloud db list [--json]
```

Prints the name, ID, engine, memory and cluster of every database in your account.

## `squarecloud db info`

```bash Usage theme={"system"}
squarecloud db info [dbID] [--json]
```

Shows the database ID, name, engine, memory, port, cluster, owner and creation date.

## `squarecloud db update`

```bash Usage theme={"system"}
squarecloud db update [dbID] [--name <name>] [--memory <MB>]
```

| Flag | Description |
| - | - |
| `--name <name>` | New database name. |
| `--memory <MB>` | New allocated memory in MB. |

Renames the database or changes its memory. Pass at least one of the two flags: without them, the command prints its help.

```bash theme={"system"}
squarecloud db update <dbID> --memory 2048
```

## `squarecloud db start`

```bash Usage theme={"system"}
squarecloud db start [dbID]
```

Starts a stopped database. If it is already running, the CLI says so (`It is already running.`) and exits with code 0.

## `squarecloud db stop`

```bash Usage theme={"system"}
squarecloud db stop [dbID]
```

Stops a running database. If it is already stopped, the CLI says so (`It is already stopped.`) and exits with code 0.

## `squarecloud db status`

```bash Usage theme={"system"}
squarecloud db status [dbID] [--all] [--raw] [--json]
```

| Flag | Description |
| - | - |
| `--all` | Shows every database instead of one: database ID, whether it is running, CPU and memory. |
| `--raw` | Prints the raw numeric stats as JSON instead of the table. |

Prints the database ID, CPU usage, memory, disk and status.

## `squarecloud db metrics`

```bash Usage theme={"system"}
squarecloud db metrics [dbID] [--json]
```

Prints the last 24 hours of the database's CPU usage, RAM usage and network traffic, one row per 5-minute data point.

## `squarecloud db credentials certificate`

```bash Usage theme={"system"}
squarecloud db credentials certificate [dbID]
```

Prints the database's TLS certificate, which clients use to connect over TLS.

```bash theme={"system"}
squarecloud db credentials certificate <dbID> > certificate.pem
# Saves the certificate to a file.
```

## `squarecloud db credentials reset`

```bash Usage theme={"system"}
squarecloud db credentials reset <password|certificate> [dbID] [-y]
```

| Flag | Description |
| - | - |
| `-y`, `--yes` | Skips the confirmation prompt. |

Rotates the password or the TLS certificate, after a `y/N` confirmation. The old one stops working immediately, so update every client that uses it. A new password is printed once; after rotating the certificate, get the new one with `db credentials certificate`.

```bash theme={"system"}
squarecloud db credentials reset password <dbID>
```

## `squarecloud db delete`

```bash Usage theme={"system"}
squarecloud db delete [dbID] [-y]
```

| Flag | Description |
| - | - |
| `-y`, `--yes` | Skips the confirmation prompt. |

<Warning>
  Deleting a database is permanent. To keep a copy of the data, run [`squarecloud db snapshot create --download`](/en/cli-reference/snapshots#squarecloud-db-snapshot-create) first.
</Warning>

Asks `Delete the database <dbID>? This action is irreversible [y/N]` before deleting.

## Related

| Command | API | JavaScript SDK | VS Code |
| - | - | - | - |
| `create` | [`POST /v2/databases`](/en/api-reference/endpoint/databases/create) | [`api.databases.create()`](/en/sdks/js/databases) | [Create database](/en/vscode-extension/features#databases) |
| `list` | [`GET /v2/users/me`](/en/api-reference/endpoint/users/me) | [`api.account.me()`](/en/sdks/js/client) | [Databases section](/en/vscode-extension/features#databases) |
| `info` | [`GET .../{database_id}`](/en/api-reference/endpoint/databases/info) | [`api.databases.get()`](/en/sdks/js/databases) | |
| `update` | [`PATCH .../{database_id}`](/en/api-reference/endpoint/databases/edit) | [`api.databases.update()`](/en/sdks/js/databases) | |
| `start` | [`POST .../start`](/en/api-reference/endpoint/databases/start) | [`api.databases.start()`](/en/sdks/js/databases) | [Start](/en/vscode-extension/features#databases) |
| `stop` | [`POST .../stop`](/en/api-reference/endpoint/databases/stop) | [`api.databases.stop()`](/en/sdks/js/databases) | [Stop](/en/vscode-extension/features#databases) |
| `status` | [`GET .../status`](/en/api-reference/endpoint/databases/status) | [`api.databases.status()`](/en/sdks/js/databases) | |
| `status --all` | [`GET /v2/databases/status`](/en/api-reference/endpoint/databases/status-all) | [`api.databases.statusAll()`](/en/sdks/js/databases) | |
| `metrics` | [`GET .../metrics`](/en/api-reference/endpoint/databases/metrics) | [`api.databases.metrics()`](/en/sdks/js/databases) | |
| `credentials certificate` | [`GET .../credentials/certificate`](/en/api-reference/endpoint/databases/credentials/get_certificate) | [`api.databases.certificate()`](/en/sdks/js/databases) | [Download TLS certificate](/en/vscode-extension/features#databases) |
| `credentials reset` | [`POST .../credentials/reset`](/en/api-reference/endpoint/databases/credentials/reset) | [`api.databases.resetCredentials()`](/en/sdks/js/databases) | |
| `delete` | [`DELETE .../{database_id}`](/en/api-reference/endpoint/databases/delete) | [`api.databases.delete()`](/en/sdks/js/databases) | [Delete](/en/vscode-extension/features#databases) |

Snapshots of databases are on [Snapshots](/en/cli-reference/snapshots#squarecloud-db-snapshot-create).
