“ERROR: must be member of role” When creating schema in PostgreSQL

前端 未结 9 571
粉色の甜心
粉色の甜心 2021-01-31 13:01

I\'m logged in with a superuser account and this is the process I\'m doing:

1-> CREATE ROLE test WITH IN ROLE testroles PASSWORD \'testpasswd\'
2-> CREATE S         


        
相关标签:
9条回答
  • 2021-01-31 13:51

    I just ran into this using Amazon RDS.

    A lot of the answers are already correct, but you can also just alter the role.

    Here was my implementation

    psql -h ${PGHOST} -p ${PGPORT:-5432} -U ${PGUSER:-postgres} -c "ALTER USER renderer WITH CREATEDB PASSWORD '$RENDERPASSWORD'"

    So while changing the password, I am also adding the CREATEDB role permission to the role.

    0 讨论(0)
  • I was facing the same issue. To resolve this, I logged in with the newly created role and created the database. Somehow, grant does not work in RDS Postgres.

    0 讨论(0)
  • 2021-01-31 13:56

    I ran into this issue when using CREATE DATABASE on Amazon RDS. I think it's essentially the same as using CREATE SCHEMA.

    When using Amazon RDS the user issuing the CREATE DATABASE must be a member of the role that will be the owner of the database. In my case, the superuser account I'm using is called root, and I'm going to create a role o which is going to own a database d:

    postgres=> CREATE ROLE o;
    CREATE ROLE
    
    postgres=> CREATE DATABASE d OWNER = o;
    ERROR:  must be member of role "o"
    
    postgres=> GRANT o TO root;
    GRANT ROLE
    
    postgres=> CREATE DATABASE d OWNER = o;
    CREATE DATABASE
    
    0 讨论(0)
提交回复
热议问题