Deleting a database cluster permanently and irreversibly destroys the cluster, its contents, and its automated backups.
Destroy a Database Cluster Using the CLI or API
How to Create a Database Using the DigitalOcean CLI
- Install
doctl
, the official DigitalOcean CLI.
- Create a personal access token and save it for use with
doctl
.
- Use the token to grant
doctl
access to your DigitalOcean account.
- Finally, run
doctl databases delete
. Basic usage looks like this, but you can read the usage docs for more details:
doctl databases delete <database-cluster-id> [flags]
The following example deletes the database cluster with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6
:
doctl databases delete f81d4fae-7dec-11d0-a765-00a0c91e6bf6
How to Destroy a Database Cluster Using the DigitalOcean API
- Create a personal access token and save it for use with the API.
- Send a DELETE request to
https://api.digitalocean.com/v2/databases/{database_cluster_uuid}
.
cURL
Using cURL:
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"
Go
Using Godo, the official DigitalOcean API client for Go:
import (
"context"
"github.com/digitalocean/godo"
)
func main() {
pat := "mytoken"
client := godo.NewFromToken(pat)
ctx := context.TODO()
_, err := client.Databases.Delete(ctx, "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30")
}
Python
Using PyDo, the official DigitalOcean API client for Python:
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
delete_resp = client.databases.destroy_cluster(database_cluster_uuid="a7abba8")
Destroy a Database Cluster Using the Control Panel
To destroy a database cluster from the control panel, open the cluster’s More menu. Click Destroy to open the cluster’s Settings page.
In the Destroy this database cluster section at the bottom of the page, click the Destroy button. This opens a Destroy database cluster confirmation window.
To permanently destroy the cluster, type or copy and paste the name of the database cluster into the text field, then click Destroy.
Destroying a database cluster destroys the backups of that database. Make sure you download any important data before you destroy a cluster.