LinuxCommandLibrary

doctl-databases-db

Manage DigitalOcean database clusters

TLDR

Run a doctl databases db command with an access token

$ doctl [[d|databases]] db [command] [[-t|--access-token]] [access_token]
copy

Retrieve the name of the given database hosted in the given database cluster
$ doctl [[d|databases]] db [[g|get]] [database_id] [database_name]
copy

List existing databases hosted within a given database cluster
$ doctl [[d|databases]] db [[ls|list]] [database_id]
copy

Create a database with the given name in the given database cluster
$ doctl [[d|databases]] db [[c|create]] [database_id] [database_name]
copy

Delete the database with the given name in the given database cluster
$ doctl [[d|databases]] db [[rm|delete]] [database_id] [database_name]
copy

SYNOPSIS

doctl databases db create <cluster-id> [--name <name>]
doctl databases db list <cluster-id> [--format <format>] [--no-header]
doctl databases db delete <cluster-id> <db-name> [--force]

PARAMETERS

--name string
    Name for the new database (required for create)

--format string
    Output columns: Name, or json,csv,table,yaml (default table)

--no-header
    Suppress column headers in output

--force
    Skip interactive confirmation for delete

DESCRIPTION

The doctl databases db command, part of the DigitalOcean CLI (doctl), enables creation, listing, and deletion of user databases within managed database clusters. DigitalOcean Managed Databases support PostgreSQL and MySQL clusters, where this subcommand handles per-cluster databases for applications.

Usage requires doctl installation, authentication via API token (doctl auth init), and a cluster ID. Subcommands streamline DB lifecycle management without cluster recreation.

Key benefits include easy setup for dev/staging/prod environments and integration with CI/CD pipelines. Output supports JSON/CSV formats for scripting. Always verify cluster engine compatibility, as databases inherit cluster settings like version and region.

CAVEATS

Requires DigitalOcean API token and cluster access. Database names must match engine rules (e.g., lowercase alphanumeric for MySQL). No undo for deletes; backups separate.

EXAMPLES

Create: doctl databases db create d1a2b3c4-5678 --name mydb
List: doctl databases db list d1a2b3c4-5678
Delete: doctl databases db delete d1a2b3c4-5678 mydb --force

REQUIREMENTS

doctl ≥1.20.0; API token with read/write databases scope. Cluster must exist.

HISTORY

Part of doctl v1.0+ (2017), with databases support added in 2018 alongside Managed Databases launch. Evolved with cluster features in v1.20+.

SEE ALSO

doctl(1), doctl databases(1), psql(1), mysql(1)

Copied to clipboard