sajad torkamani

Create the file repository config

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Import the repository signing key

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - 

Update the package lists

sudo apt-get update 

Install package

Check the release notes for available versions.

Assuming, you want to install version 14, run:

sudo apt-get -y install postgresql-14

Access psql prompt

Test everything is setup by connecting to the psql prompt.

sudo -u postgres psql

Refer to How do postgres roles work for more info on how access can be configured.

Sources

Tagged: Postgres