arrow-downInstalling Database

This guide explains how to install PostgreSQL 15.4 on Linux using the PostgreSQL APT repository.

Update and Install Prerequisites

Open your terminal and run the following command to update your system packages and install necessary dependencies.

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget gnupg lsb-release

Add PostgreSQL APT Repository

Import the PostgreSQL GPG key

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

Add the PostgreSQL repository to your system:

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

Install PostgreSQL 15.4

Update the package list again to include the PostgreSQL repository

sudo apt update

Install PostgreSQL 15.4

sudo apt install -y postgresql-15

Start and Enable PostgreSQL Service

Start the PostgreSQL service

Enable PostgreSQL to start on boot

Verify the service status

Configure PostgreSQL

  • Change postgres password in /etc/postgresql/15/main/pg_hba.conf

Restart the PostgreSQL service after making changes

circle-info

Congratulations! PostgreSQL 15.4 is now installed and configured on your Ubuntu system.

Last updated