LinuxCommandLibrary

doctl-databases

Manage DigitalOcean managed databases

TLDR

Run a doctl databases command with an access token

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

Get details for a database cluster
$ doctl [[d|databases]] [[g|get]]
copy

List your database clusters
$ doctl [[d|databases]] [[ls|list]]
copy

Create a database cluster
$ doctl [[d|databases]] [[c|create]] [database_name]
copy

Delete a cluster
$ doctl [[d|databases]] [[rm|delete]] [database_id]
copy

SYNOPSIS

doctl databases <command> [options]

The doctl databases command is a subcommand group of the doctl CLI, used to interact with DigitalOcean's Managed Databases service. Common <commands> include:
  create: Create a new managed database cluster.
  list: List all managed database clusters.
  get: Retrieve details for a specific cluster.
  update: Modify an existing database cluster's configuration.
  delete: Permanently delete a database cluster.
  connection: Show connection details for a database cluster.
  users: Manage database users within a cluster.
  pools: Manage PostgreSQL connection pools.
  replica: Manage read-only replicas for a database cluster.

Example Usage:
  doctl databases create --engine pg --version 14 --size s-2vcpu-4gb --region nyc3 --name my-pg-db
  doctl databases list --format UUID,Name,Engine,Region,Status
  doctl databases get my-pg-db

PARAMETERS

--format <columns>
    Comma-separated list of columns to display in the output. Useful for list and get commands to customize table views.

--output <json|yaml|text>
    Specify the output format. Defaults to human-readable text for tables; JSON or YAML provide structured data.

--no-headers
    Suppress table headers from the output, often used for scripting.

--engine <engine>
    Specifies the database engine (e.g., pg for PostgreSQL, mysql for MySQL, redis for Redis, mongodb for MongoDB). Required for create.

--version <version>
    Defines the specific version of the database engine (e.g., 14 for PostgreSQL, 8 for MySQL). Required for create.

--size <slug>
    Determines the resource plan (CPU, RAM, storage) for the cluster (e.g., s-2vcpu-4gb). Required for create; also used with update and replica.

--region <slug>
    Specifies the DigitalOcean datacenter region where the cluster will be deployed (e.g., nyc3, fra1). Required for create; also used for replica.

--name <name>
    A unique, user-friendly name for the database cluster. Required for create; used to identify clusters in get, update, delete, and related subcommands.

--num-nodes <count>
    The desired number of nodes in the database cluster. Defaults to 1 for most engines. Used for create and update.

--private-network
    Enables private network (VPC) access for the database cluster, enhancing security and reducing egress costs. Used for create and update.

--force
    Bypasses the confirmation prompt for destructive operations like delete. Use with caution.

DESCRIPTION

doctl databases is the command group within the DigitalOcean command-line interface (doctl) used to interact with and manage DigitalOcean Managed Databases. It allows users to create, list, retrieve details for, update, and delete database clusters, as well as manage users, connection pools, and replica nodes for various database engines like PostgreSQL, MySQL, Redis, and MongoDB. This command group simplifies database operations directly from the terminal, enabling automation and scripting of database lifecycle management for cloud-based database instances.

CAVEATS

Usage of doctl databases requires a DigitalOcean account and an API token with appropriate read/write permissions for database resources. Creating and operating database clusters incurs charges based on their size, number of nodes, and data transfer. Deleting a database cluster is an irreversible action that will permanently remove all associated data and backups.

DIGITALOCEAN API TOKEN

doctl authenticates using a DigitalOcean API token. This token can be configured using doctl auth init or by setting the DIGITALOCEAN_ACCESS_TOKEN environment variable. Ensure the token has the necessary permissions to manage databases.

MANAGED DATABASE LIFECYCLE

doctl databases supports the full lifecycle of managed databases, from creation and configuration (e.g., size, region, private networking) to user and connection pool management, read replica creation, and eventual deletion. It also provides commands to retrieve crucial connection details and manage database-specific settings.

HISTORY

doctl, the official command-line client for the DigitalOcean API, has been continuously developed to provide a comprehensive interface for managing cloud resources. The databases command group was progressively introduced as DigitalOcean expanded its offering of managed database services (PostgreSQL, MySQL, Redis, MongoDB), integrating seamless CLI management into the doctl suite. This integration allows developers and system administrators to automate database provisioning, scaling, and maintenance tasks directly from their terminals or scripts.

SEE ALSO

doctl(1), doctl compute(1), doctl kubernetes(1), doctl registry(1), doctl vpc(1), doctl app(1)

Copied to clipboard