Code Conservatory
How To Install PostgreSQL on Ubuntu 20.04
Photo by from

How To Install PostgreSQL on Ubuntu 20.04

Install PostgreSQL

$ sudo apt update
$ sudo apt install postgresql postgresql-contrib
$ sudo systemctl start postgresql.service

Creating a New Role

$ sudo -u postgres createuser --interactive
Output
Enter name of role to add: john
Shall the new role be a superuser? (y/n) y

Creating a New Database

$ sudo -u postgres createdb john

Opening a Postgres Prompt with the New Role

$ sudo adduser john
$ sudo -u john psql
$john=# \conninfo

Output

You are connected to database "john" as user "john" via socket in "/var/run/postgresql" at port "5432".