I followed the doc to use createuser xxx -g postgres -i
to create an account as a member of postgres, but it seems that the new user xxx doesn't have any privileges of postgres, such as create user and create db. Why is that?
From the docs:
The role attributes
LOGIN
,SUPERUSER
,CREATEDB
, andCREATEROLE
can be thought of as special privileges, but they are never inherited as ordinary privileges on database objects are. You must actuallySET ROLE
to a specific role having one of these attributes in order to make use of the attribute.
Your user has the permission to assume the role of postgres
, but it doesn't inherit the permission to create a user or database. You'd need to grant (ALTER ROLE
, actually) that explicitly. (Though the user could grant it themselves).