postgresql create user with password grant all privileges code example

Example 1: grant all privileges database postgres to user

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name TO username;

Example 2: postgres create user with superuser privileges

sudo -u postgres createuser -s -i -d -r -l -w <<username>>
sudo -u postgres psql -c "ALTER ROLE <<username>> WITH PASSWORD '<<password>>';"

Example 3: grant all privileges database postgres to user

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA schema_name TO username;

Tags:

Sql Example