Wednesday, April 25, 2018

[google-cloud-sql-discuss] Re: SQL import error (Cloud SQL exported instance)


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 "myjob@project-1.iam.gserviceaccount.com" is the active account that gcloud command uses it credentials to call APIs. 

me@debian9:~$ gcloud auth list
                  Credentialed Accounts
ACTIVE  ACCOUNT
        100000000000-compute@developer.gserviceaccount.com
*       myjob@project-1.iam.gserviceaccount.com
        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...
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.



--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/10c78c2e-4a50-4824-9b31-49c3b3158deb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment