Importing a Large SQL File Into Google Cloud SQL
Cloud SQL imports from a bucket, not your laptop. The gsutil + gcloud workflow, the permissions gotcha, and how to handle multi-GB dumps.
Cloud SQL doesn't import from your local disk — it imports from a Google Cloud Storage bucket. Once you know the flow it's reliable even for big dumps, but the service-account permission step trips almost everyone up the first time.
Step 1: Upload the dump to a bucket
gsutil cp dump.sql.gz gs://your-bucket/dump.sql.gzCloud SQL imports gzipped SQL directly, so keep it compressed — uploads are faster and the import handles .gz natively.
Step 2: Grant the Cloud SQL service account read access
This is the step people miss. Each Cloud SQL instance has its own service account that must be allowed to read the bucket object:
# Find the instance's service account
SA=$(gcloud sql instances describe my-instance \
--format='value(serviceAccountEmailAddress)')
# Grant it object read on the bucket
gsutil iam ch serviceAccount:$SA:objectViewer gs://your-bucketIf the import fails immediately with a permissions error, this grant is missing or hasn't propagated. Re-run the gsutil iam ch command and wait a minute.
Step 3: Run the import
gcloud sql import sql my-instance \
gs://your-bucket/dump.sql.gz \
--database=your_databaseHandling multi-GB dumps
- Cloud SQL runs one import at a time per instance — large imports block other operations, so plan a window
- An import can't be cancelled cleanly once running; a failed huge import means restoring or starting fresh
- Temporarily scale the instance up (more vCPU/RAM) for the import, then scale back down
- Split the dump so a failure costs you one chunk, not the whole multi-hour run
De-risk a big Cloud SQL import
Split the dump into per-table or size-bounded chunks you can import and verify one at a time.
Open SQLSplitCloud SQL doesn't grant SUPER privilege, so dumps containing DEFINER=`user`@`host` on views/triggers will fail. Remove them before uploading.
Frequently Asked Questions
How do I import a SQL file into Google Cloud SQL?
Upload the dump to a Cloud Storage bucket with gsutil, grant the instance's service account objectViewer on that bucket, then run gcloud sql import sql INSTANCE gs://bucket/dump.sql.gz --database=DB. Cloud SQL imports from buckets, not local disk.
Why does my Cloud SQL import fail with a permissions error?
The Cloud SQL instance's service account needs read access to the bucket object. Get the account with gcloud sql instances describe and grant it with gsutil iam ch serviceAccount:SA:objectViewer gs://bucket.
Does Cloud SQL accept gzipped SQL dumps?
Yes. Cloud SQL imports .sql.gz files directly, so keep your dump compressed for faster uploads. It also accepts plain .sql. Strip any DEFINER clauses first since Cloud SQL has no SUPER privilege.