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, ispermanently lost when that instance is deleted. To preserve your data,export it to Cloud Storagebefore you delete it. The Cloud SQL Admin role includes the permission to deletethe instance. To prevent accidental deletion, grant this role only as needed.Additionally, considerdeletion protection.Note the following when you plan to delete an instance:
- You cannot delete an instance that has any replicas. You must delete allreplicas first.You can reduce your chances of accidentally deleting aninstance by creating a replica; a replica must be deleted before its primaryinstance.
- After you delete an instance, it might continue to appear in your projectwith an "unknown" size but with a "Being deleted" status. This is normal and theinstance disappears completely after a brief period of time.
- It can take up to four days for the underlying resources related to an instanceto be completely deleted, with the exception of read replicas, which are oftendeleted within a few minutes.
- The deleted instance name can be reused immediately to create a new instance.
- Ifdeletion protection is enabled on an instance, you must disable it beforedeleting the instance.
- In case of contingencies, take afinal backup to restore the deleted instance.
Required permissions
By default, only user or service accounts with theCloud SQL Admin
(roles/cloudsql.admin
)orOwner
(roles/owner
) role have the permission to delete aCloud SQL instance (cloudsql.instances.delete
).
You can also define anIAM custom rolefor the user or service account that includes thecloudsql.instances.delete
permission. This permission issupported inIAM custom roles.
Delete an instance
You can delete a Cloud SQL instance by using the Google Cloud console,gcloud CLI
, or the API. If you want to retain backupsfor your instance prior to deleting, seeManage retained backups.Note:Before you delete an instance, confirm that it's safe to do so. Then, confirm thatdeletion protection is deactivated for the instance. Also, we strongly recommend that you take a final backup of the instance before you delete it.
If you usedCloud Key Management Service to encrypt your instance, but the KMS keys aren't accessible, then after you delete the instance, the status of the final backup isFAILED
. If this occurs, then request to recover your instance by contactingCloud Customer Care within 4 days from the time that you deleted the instance.
If you delete an instance that hasPrivate Service Connect enabled for it, then the following actions occur:
- Theservice attachment is removed automatically. However, thePrivate 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 correspondingDNS zone andDNS record.
Console
In the Google Cloud console, go to theCloud SQL Instances page.
- To open theOverview page of an instance, click the instance name.
- ClickDelete.
- In theDelete instance dialog, complete the following actions:
- In the text field, enter the instance ID that appears.
If you want to take afinal backup of the instance, leave theTake a final backup checkbox selected, expand theRetention options menu, and then, in theRetain for field, enter the number of days to retain the final backup. You can specify from 1 to 365 days.
If you want to delete the instance without taking a final backup, then clear the checkbox.
- In theDescribe this backup text area, you can provide a description of the backup.
- ClickDelete.
gcloud
To delete an instance, use thegcloud sql instances delete
command:
gcloudsqlinstancesdeleteINSTANCE_NAME\--project=PROJECT_ID
Make the following replacements:
- INSTANCE_NAME: the name of the instance
- PROJECT_ID: the ID orproject number of the Google Cloud project that contains the instance that you want to delete
Note:If you want to take a final backup of the instance, then use the following flags:
--enable-final-backup
: set the value of this flag totrue
to take a final backup. If you want to delete the instance without taking a final backup, then set the value tofalse
.--final-backup-description
: provide details about the final backup. The default value is empty.--final-backup-ttl-days
: specify the number of days to retain the final backup. This is known as time to live (TTL). The default value is 30 days. The allowed retention period varies, from 1 to 365 days. To provide the retention period, use either this flag or--final-backup-expiry-time
.--final-backup-expiry-time
: this is a timestamp (in UTC) of when the backup is set to expire. This can't exceed 1 year. To provide the retention period, use either this flag or--final-backup-ttl-days
.
REST v1
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID orproject number of the Google Cloud project that contains the instance that you want to delete
- INSTANCE_NAME: the name of the instance
Note:If you want to take a final backup of the instance, then use the following query parameters:
enable_final_backup
: set the value of this parameter totrue
to take a final backup. If you want to delete the instance without taking a final backup, then set the value tofalse
.final_backup_description
: provide details about the final backup. The default value is empty.final_backup_ttl_days
: specify the number of days to retain the final backup. This is known as time to live (TTL). The default value is 30 days. The allowed retention period varies, from 1 to 365 days. To provide the retention period, use either this parameter orfinal_backup_expiry_time
.final_backup_expiry_time
: this is a timestamp (in UTC) of when the backup is set to expire. This can't exceed 1 year. To provide the retention period, use either this parameter orfinal_backup_ttl_days
.
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 thegcloud
CLI with your user account by runninggcloud init
orgcloud auth login
, or by usingCloud Shell, which automatically logs you into thegcloud
CLI . You can check the currently active account by runninggcloud 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)
Note: The following command assumes that you have logged in to thegcloud
CLI with your user account by runninggcloud init
orgcloud auth login
. You can check the currently active account by runninggcloud auth list
.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"}
REST v1beta4
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID orproject number of the Google Cloud project that contains the instance that you want to delete
- INSTANCE_NAME: the name of the instance
Note:If you want to take a final backup of the instance, then use the following query parameters:
enable_final_backup
: set the value of this parameter totrue
to take a final backup. If you want to delete the instance without taking a final backup, then set the value tofalse
.final_backup_description
: provide details about the final backup. The default value is empty.final_backup_ttl_days
: specify the number of days to retain the final backup. This is known as time to live (TTL). The default value is 30 days. The allowed retention period varies, from 1 to 365 days. To provide the retention period, use either this parameter orfinal_backup_expiry_time
.final_backup_expiry_time
: this is a timestamp (in UTC) of when the backup is set to expire. This can't exceed 1 year. To provide the retention period, use either this parameter orfinal_backup_ttl_days
.
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 thegcloud
CLI with your user account by runninggcloud init
orgcloud auth login
, or by usingCloud Shell, which automatically logs you into thegcloud
CLI . You can check the currently active account by runninggcloud 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)
Note: The following command assumes that you have logged in to thegcloud
CLI with your user account by runninggcloud init
orgcloud auth login
. You can check the currently active account by runninggcloud auth list
.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"}
Restore a deleted instance
When you delete an instance, Cloud SQL deletes all resources for the instance, includingon-demand backups andautomated backups.
If you take afinal backup as part of deleting an instance, then you can use this backup to recover the instance, either by creating an instance from the final backup or by restoring the final backup to an existing instance.
If you use a final backup to recover your instance, then your instance might have a different IP address from the original, deleted instance.
If you delete an instance accidentally without taking a final backup, then you can request to recover the instance by contactingCloud Customer Care within 4 days from the time that the instance is deleted. If the instance can be recovered, then the instance configuration, including IP addresses used before the deletion, are restored. All backups available at the time of deletion are also recovered.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-14 UTC.