Troels
Troels

Reputation: 352

Upgrade user to superuser in Postgres in Google Cloud

How do I create a user with the superuser role in Postgres server with Google Cloud console?

When I create databases in Google Cloud, the default user is a non-superuser. From this role, it is not possible to upgrade.

Upvotes: 12

Views: 8889

Answers (2)

JDOaktown
JDOaktown

Reputation: 4474

Here's my own script:

GRANT cloudsqlimportexport, cloudsqlsuperuser, pg_read_all_data, pg_write_all_data, postgres TO myawsumuser WITH ADMIN OPTION;

GRANT ALL PRIVILEGES ON DATABASE mytestdb1 TO myawsumuser WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON DATABASE postgres TO myawsumuser WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO myawsumuser with grant option;
GRANT USAGE ON SCHEMA public TO myawsumuser with grant option;

GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO myawsumuser with admin option;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO myawsumuser with grant option;

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO myawsumuser with grant option;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO myawsumuser with grant option;

Good links: https://cloud.google.com/sql/docs/postgres/users

How to grant all privileges on views to arbitrary user

Upvotes: -1

Vao Tsun
Vao Tsun

Reputation: 51629

no way:

https://cloud.google.com/sql/docs/postgres/users

The postgres user is part of the cloudsqlsuperuser role, and has the following attributes (privileges): CREATEROLE, CREATEDB, and LOGIN. It does not have the SUPERUSER or REPLICATION attributes.

Upvotes: 10

Related Questions