Last Updated: September 29, 2021
·
364
· apeeyush

Getting started with PostgreSQL

Install PostgreSQL if not already present.

Change user to postgres using

sudo su postgres

Now, start CLI for PostgreSQL by typing

psql

A few basic commands :

\l      # List all Databases
\q     # Quit
CREATE DATABASE *Database Name*

To Create a new login role/user for PostgreSQL :

First open psql as postgres(root) user. Then do the following:

CREATE USER *username* WITH PASSWORD '*password*';

You can later alter user. For example, to make the user a superuser, type:

ALTER USER *username* with SUPERUSER;