doctl Verified current stable Not installed? Cloud Infrastructure

Doctl / Create Database In Cluster

Create Database In Cluster

Provision a new database within a specified DigitalOcean cluster.

$
Terminal
doctl d db c <database_id> <database_name>

When To Use

When scaling applications to accommodate increasing data volume or user load.

Pro Tip

Consider the choice of database engine; switching between versions or engines post-creation can be complicated.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Creating database...

Database ID: db-123456
Database Name: my_database
Status: Creating

Success! Database my_database is being created in cluster db-123456.

Anatomy of Output

Understanding the result

Creating database: database_name in cluster: database_id Creation Status

Confirms target cluster for database provisioning.

Database created successfully, ID: 123456 Output

Indicates successful creation with new database ID.

Power User Variants

Optimized versions

doctl databases db create database_id database_name --engine postgres

Specify the database engine during creation.

Unix Pipeline

Shell combinations

doctl databases db create --help

Access additional help and options for database creation.

Troubleshooting

Common pitfalls

Error: Cluster ID not found

Solution: Verify that the given cluster ID matches an existing cluster.

Error: Invalid database name

Solution: Double-check naming conventions for databases in the DigitalOcean environment.

Error: Unauthorized access

Solution: Ensure your access token has rights to create databases within the cluster.

Command Breakdown

What each part is doing

doctl
Base Command
The executable that performs this operation. Here it runs Doctl before the shell applies any redirect operators.
d
d|databases
The value supplied for d|databases.
c
c|create
The value supplied for c|create.
<database_id>
database id
The value supplied for database id.
<database_name>
database name
The value supplied for database name.

How To Run

Execution path

  1. Step 1

    Run `doctl databases create db-123456 my_database` to initiate the database creation.

  2. Step 2

    Monitor the status with `doctl databases get db-123456` until it's ready.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.