1
votes

I have a Postgresql database that is running on premises which I want to import into Google Cloud SQL. My database is called test and is owned by user test

Steps I've taken:

  1. created Cloud SQL instance
  2. created database on Cloud SQL instance:

    curl --header "Authorization: Bearer XXXXX" \ --header 'Content-Type: application/json' \ --data '{"project": "YYYYYY", "instance": "dev", "name": "test"}' \

    https://www.googleapis.com/sql/v1beta4/projects/YYYYYY/instances/dev/databases -X POST

  3. Created test user:

    gcloud beta sql users create test host --instance=dev --password=test

  4. Dumped DB from source db with pg_dump
  5. Tried to restored ... got this error:
    ERROR: must be member of role test

So how do I execute import under test user?

1

1 Answers

6
votes

To answer my own question...

Just use --no-acl --no-owner with pg_dump to remove all ownership altering, and it will work.