Wednesday, November 1, 2023

Postgresql 16 installation on ubuntu 22.04

Postgresql 16 is the latest postgresql version, released on Sept 2023. To install postgresql 16 on ubuntu 22.04, just follow below steps

First, create a postgresql repository file
$ sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Then, import repository signing key
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Update the package list
$ sudo apt update

Install postgresql
$ sudo apt install postgresql-16 -y

Configure postgresql to listen on all interfaces rather than just localhost
- Edit /etc/postgresql/16/main/postgresql.conf
$ sudo vi /etc/postgresql/16/main/postgresql.conf
- Add below configuration
listen_addresses = '*'
- Save and exit

Start postgresql
$ sudo systemctl start postgresql

Enable postgresql on boot
$ sudo systemctl enable postgresql

Allow postgresql port (5432) on ufw
$ sudo ufw allow 5432/tcp

Access to postgresql database and check version
$ sudo su - postgres
postgres@host:~$ psql
postgres=# select version();

The output should look like below








Type \q to exit psql


No comments:

Post a Comment