How to Install PostgreSQL For Local Rails Development On Ubuntu 19.04

Before install PostgreSQL we need to update apt package list to do so :

sudo apt update

After that we can install PostgreSQL and dependencies :

sudo apt install postgresql postgresql-contrib

To switch into Postgres account :

sudo -i -u postgres

Now you can access PostgreSQL prompt by running command :

psql

Exit out of the PostgreSQL prompt by typing :

postgres=# \q

To accessing a PostgreSQL prompt without switching accounts just run :

sudo -u postgres psql

To change your postgres user password, run this inside your PostgreSQL prompt :

postgres=# \password