Friday, August 23, 2019

Create user with all permission on database in postgres

Sometime we want to create a user and role in postgresql that he can create a new database, schema and so on so we can the like this below.

CREATE USER user1 WITH PASSWORD 'userPassword';
CREATE DATABASE dbUser1 OWNER user1;
GRANT ALL PRIVILEGES ON DATABASE dbUser1 TO user1;
GRANT ALL ON DATABASE dbUser1 TO user1;
ALTER ROLE user1 WITH LOGIN SUPERUSER INHERIT CREATEDB CREATEROLE NOREPLICATION;

No comments:

Post a Comment