Google Cloud SQL import - ERROR: HTTPError 403: The client is not authorized to make this request
Solution 1
Make sure the instance-name is correct. I had the same error, it went away as soon as I corrected the instance-name.
Solution 2
I had this problem, my instance name was correct. Turns out I was in the wrong GCP project. Make sure you switch to the correct [target] project or use the project argument:
gcloud sql instances export my-cloud-sql-instance gs://connect-to-the-cloud-sql.appspot.com/my-cloud-sql-instance-backup --project=<your target project>
Solution 3
In my case it was because the cloud sql instance service account didn't have the correct permissions on the storage bucket I was trying to import from.
-
Describe the instance you are importing to:
gcloud sql instances describe [INSTANCE_NAME]
Copy the
serviceAccountEmailAddress
field.Use
gsutil iam
to grant thelegacyBucketWriter
andobjectViewer
Cloud IAM roles to the service account for the bucket.-
Import the database:
gcloud sql import sql [INSTANCE_NAME] gs://[BUCKET_NAME]/[IMPORT_FILE_NAME] \ --database=[DATABASE_NAME]
Solution 4
It might sound too obvious, but your service account really may be missing access rights for importing data. Check that it has correct cloudsql.instances.import
policy installed on IAM&Admin page.
Beginner
Updated on June 13, 2022Comments
-
Beginner almost 2 years
I trying to import a database stored in the Cloud Storage using the command:
gcloud sql instances import instance-name gs://connect-to-the-cloud-sql.appspot.com/my-cloud-sql-instance-backup
But, I am getting error:
ERROR: (gcloud.sql.instances.import) HTTPError 403: The client is not authorized to make this request.
I've already logged in using:
gcloud auth login