SQL Error [42501]: ERROR: permission denied to create role

Roan van Heerden 0 Reputation points
2023-04-04T09:30:18.1566667+00:00

I am trying to create users and schemas in my postgres databse. I am logged in as the database admin user. However when I try to run the following line I get this error: SQL Error [42501]: Line - CREATE USER airbp_location_master WITH PASSWORD 'airbp_location_master'; Error - ERROR: permission denied to create role Please see attached I have logged in as the databaseScreenshot 2023-04-04 at 11.28.47

Screenshot 2023-04-04 at 11.29.05

admin

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. ShaktiSingh-MSFT 13,911 Reputation points Microsoft Employee
    2023-04-04T10:31:35.6333333+00:00

    Hi Roan van Heerden,

    Welcome to Microsoft Q&A forum and thanks for using Azure services.

    As I understand, you are getting error "ERROR: permission denied to create role" when creating user in Azure Database for PostgreSQL.

    Could you please SET ROLE before using the create role privilege and see if this helps in your case. Connect to the user airbp_location_master and issue below command:

    SET ROLE group1; CREATE ROLE newuser;

    Refer doc. Here is a stackoverflow thread which might also help: Logged in as postgres but getting the error createuser: creation of new role failed: ERROR: must be superuser to create superusers

    Hope this helps. If not, please let us know so that we can further investigate.

    Thank you.

    0 comments No comments