Send feedback
Delete instances
Stay organized with collections
Save and categorize content based on your preferences.
This page describes how to delete Cloud SQL instances.
Warning: All data on an instance, including backups, is
permanently lost when that instance is deleted. To preserve your data,
export it to Cloud Storage
before you delete it. The Cloud SQL Admin role includes the permission to delete
the instance. To prevent accidental deletion, grant this role only as needed.
Additionally, consider
deletion protection .
Note the following when you plan to delete an instance:
You cannot delete an instance that has any replicas. You must delete all
replicas first.
You can reduce your chances of accidentally deleting an
instance by creating a replica; a replica must be deleted before its primary
instance.
After you delete an instance, it might continue to appear in your project
with an "unknown" size but with a "Being deleted" status. This is normal and the
instance disappears completely after a brief period of time.
It can take up to a week for the underlying resources related to an instance
to be completely deleted, with the exception of read replicas, which are often
deleted within a few minutes.
The deleted instance name can be reused immediately to create a new instance.
If
deletion protection is enabled on an instance, you must disable it before
deleting the instance.
Required permissions
By default, only user or service accounts with the
Cloud SQL Admin
(roles/cloudsql.admin
)
or Owner
(roles/owner
) role have the permission to delete a
Cloud SQL instance (cloudsql.instances.delete
).
You can also define an IAM custom role
for the user or service account that includes the cloudsql.instances.delete
permission. This permission is
supported in
IAM custom roles.
Delete an instance
You can delete a Cloud SQL instance by using gcloud CLI or the API.
Note: Before you delete an instance, confirm that it's safe to do so. Then, confirm that deletion protection is deactivated for the instance.
If you delete an instance that has Private Service Connect enabled for it, then the following actions occur:
The service attachment is removed automatically. However, the Private Service Connect endpoint that points to the service attachment isn't deleted automatically. By listing the forwarding rule that's associated with the endpoint, you can see that the rule has a CLOSED
status. After you receive this status, you can delete the endpoint.
You see the connection to the endpoint time out.
To avoid incurring additional costs, we strongly recommend that you also delete the corresponding DNS zone and DNS record .
Console
In the Google Cloud console, go to the Cloud SQL Instances page.
Go to Cloud SQL Instances
To open the Overview page of an instance, click the instance name.
Click Delete .
In the Delete database instance dialog, click OK .
gcloud
To delete an instance, use the gcloud sql instances delete
command:
gcloud sql instances delete INSTANCE_NAME \
--project= PROJECT_ID
Make the following replacements:
INSTANCE_NAME : the name of the instance
PROJECT_ID : the ID or project number of the Google Cloud project that contains the instance that you want to delete
REST v1
Before using any of the request data,
make the following replacements:
PROJECT_ID : the ID or project number of the Google Cloud project that contains the instance that you want to delete
INSTANCE_NAME : the name of the instance
HTTP method and URL:
DELETE https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_NAME
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Note:
The following command assumes that you have logged in to
the gcloud
CLI with your user account by running
gcloud init
or
gcloud auth login
, or by using Cloud Shell ,
which automatically logs you into the gcloud
CLI
.
You can check the currently active account by running
gcloud auth list
.
Execute the following command:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_NAME "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method DELETE ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_NAME " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /instances/INSTANCE_NAME ",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-15T00:10:22.078Z",
"operationType": "DELETE",
"name": "OPERATION_ID ",
"targetId": "INSTANCE_NAME ",
"selfLink": "https://sqladmin.googleapis.com/v1/projects/PROJECT_ID /operations/OPERATION_ID ",
"targetProject": "PROJECT_ID "
}
To see how the
underlying REST API request
is constructed for this task, see the
APIs Explorer on the instances:delete page .
REST v1beta4
Before using any of the request data,
make the following replacements:
PROJECT_ID : the ID or project number of the Google Cloud project that contains the instance that you want to delete
INSTANCE_NAME : the name of the instance
HTTP method and URL:
DELETE https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /instances/INSTANCE_NAME
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Note:
The following command assumes that you have logged in to
the gcloud
CLI with your user account by running
gcloud init
or
gcloud auth login
, or by using Cloud Shell ,
which automatically logs you into the gcloud
CLI
.
You can check the currently active account by running
gcloud auth list
.
Execute the following command:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /instances/INSTANCE_NAME "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred" } Invoke-WebRequest ` -Method DELETE ` -Headers $headers ` -Uri "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /instances/INSTANCE_NAME " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{
"kind": "sql#operation",
"targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /instances/INSTANCE_NAME ",
"status": "PENDING",
"user": "user@example.com",
"insertTime": "2020-01-15T00:10:22.078Z",
"operationType": "DELETE",
"name": "OPERATION_ID ",
"targetId": "INSTANCE_NAME ",
"selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID /operations/OPERATION_ID ",
"targetProject": "PROJECT_ID "
}
To see how the
underlying REST API request
is constructed for this task, see the
APIs Explorer on the instances:delete page .
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-01-27 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-27 UTC."],[],[]]