DEV Community

Nick F
Nick F

Posted on

Postgesql - create a user for a database

How to setup a new user and give that user permission over a database? I found this a hard question to answer, so I'm writing down my soltuion.

This worked for me on Postresql 15.

You need a superuser account, to create the database.

create database <database name>;
create user <user name> with encrypted password '<password>';
alter database <database name> owner to <user name>;
Enter fullscreen mode Exit fullscreen mode

At that point, the user you created can login and create/edit/delete tables as you would expect within that one database.

Top comments (0)