SQL import error (Cloud SQL exported instance)

1,856 views
Skip to first unread message

Brett Peary

unread,
Apr 25, 2018, 12:59:16 PM4/25/18
to Google Cloud SQL discuss
I have a working project with a Cloud SQL database that I want to import into a new project, an exact clone of the working one. 

I exported the SQL instance to a bucket in the working project. I then transfered that SQL dump over to a bucket in the new project. 

From there, I tried importing the SQL dump, but I get an unknown error, so I went moved to the CLI. 

Here are the commands I ran following the docs https://cloud.google.com/sql/docs/postgres/import-export/importing ...

gcloud sql instances describe  myapp-wp-db-app-v2

// serviceAccountEmailAddress in the output (a fake version of it)

// gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:W gs://[BUCKET_NAME]
gsutil acl ch -u 5vfxzdlh6h7u4...@sparkle-boots-27.iam.gserviceaccount.com:W gs://import-myapp-wp-app-v2

// gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:R gs://[BUCKET_NAME]/[IMPORT_FILE_NAME]
gsutil acl ch -u 5vfxzdlh6h7u4...@sparkle-boots-27.iam.gserviceaccount.com:R gs://import-myapp-wp-app-v2/Cloud_SQL_Export_2018-04-24 (20:48:52)/

// gcloud sql import sql [INSTANCE_NAME] gs://[BUCKET_NAME]/[IMPORT_FILE_NAME] \
//                            --database=[DATABASE_NAME]

gcloud sql import sql myapp-wp-db-app-v2 gs://import-myapp-wp-app-v2/Cloud_SQL_Export_2018-04-24 (20:48:52)/ \
                            --database=wordpress_db


The last command, in the CLI, give me...
Importing data into Cloud SQL instance...failed.
ERROR: (gcloud.sql.import.sql) ERROR_RDBMS
And "gs://import-myapp-wp-app-v2/Cloud_SQL_Export_2018-04-24 (20:48:52)/: Not found (bad bucket name?)" in the Cloud SQL operations log. 

The same command without the trailing slash after the file name give me
Importing data into Cloud SQL instance...failed.
ERROR: (gcloud.sql.import.sql) INTERNAL_ERROR
And "An unknown error occurred." in the Cloud SQL operations log. 

The docs says that an "ERROR_RDBMS" is likely a permissions problem, but it does not elaborate. I thought that since I had exported from Cloud SQL the SQL dump would be fine for importing into Cloud SQL. 

Any direction would be appreciated. 

Cheers.



Kamran (Google Cloud Support)

unread,
Apr 25, 2018, 8:01:02 PM4/25/18
to google-cloud...@googlegroups.com

Hello Brett,

gcloud command uses the credential of user account or service account which is active in the machine you run the command. This account can be verified by running gcloud auth list command. The active account has a asterisk front of it. The following example shows that "my...@project-1.iam.gserviceaccount.com" is the active account that gcloud command uses its credentials to call APIs. 

me@debian9:~$ gcloud auth list
                  Credentialed Accounts
ACTIVE  ACCOUNT
        k.....@google.com

in your case, you should run the gcloud command with an active account which have enough permissions to be able to read the objects (the exported database file) from the specified bucket and write them to the your Cloud SQL instance.

I hope this helps.



On Wednesday, April 25, 2018 at 12:59:16 PM UTC-4, Brett Peary wrote:
I have a working project with a Cloud SQL database that I want to import into a new project, an exact clone of the working one. 

I exported the SQL instance to a bucket in the working project. I then transfered that SQL dump over to a bucket in the new project. 

From there, I tried importing the SQL dump, but I get an unknown error, so I went moved to the CLI. 

Here are the commands I ran following the docs https://cloud.google.com/sql/docs/postgres/import-export/importing ...

gcloud sql instances describe  myapp-wp-db-app-v2

// serviceAccountEmailAddress in the output (a fake version of it)

// gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:W gs://[BUCKET_NAME]
gsutil acl ch -u 5vfxzdlh6h7u43tc5onthaevia@sparkle-boots-27.iam.gserviceaccount.com:W gs://import-myapp-wp-app-v2

// gsutil acl ch -u [SERVICE_ACCOUNT_ADDRESS]:R gs://[BUCKET_NAME]/[IMPORT_FILE_NAME]
gsutil acl ch -u 5vfxzdlh6h7u43tc5onthaevia@sparkle-boots-27.iam.gserviceaccount.com:R gs://import-myapp-wp-app-v2/Cloud_SQL_Export_2018-04-24 (20:48:52)/

// gcloud sql import sql [INSTANCE_NAME] gs://[BUCKET_NAME]/[IMPORT_FILE_NAME] \
//                            --database=[DATABASE_NAME]

gcloud sql import sql myapp-wp-db-app-v2 gs://import-myapp-wp-app-v2/Cloud_SQL_Export_2018-04-24 (20:48:52)/ \
                            --database=wordpress_db


The last command, in the CLI, give me...

Brett Peary

unread,
Apr 25, 2018, 8:14:35 PM4/25/18
to Google Cloud SQL discuss
Thanks for your reply. 

I was able to get around my import issue by using the Console. I read in another thread that you have to export and import specific databases not a whole instance. 

I will try your method next time. Thank you. 
Reply all
Reply to author
Forward
0 new messages