Add Role to PostgreSQL Server

Add role to login and create databases in your postgres server

To start using PostgreSQL, we will need a user and a database.

First, we'll switch to the postgres user account on our instance.

sudo su postgres

To run PostgresSQL, type

psql

In the next two lines, we'll create a user role who will be able to login and create databases (3). Replace username and 'password' with your own:

CREATE ROLE username 
WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'password';

To stop running PostgresSQL, type

\q

To log out of the postgres account, type

exit

Last updated