PostgreSQL is the world’s most advanced open source relational database management system (RDBMS). It was created in the early 1990s by Rob Myers and Bruce Momjian. PostgreSQL is known for its reliability, scalability, and ease of use. It is popular among developers for its ability to handle large volumes of data.
PostgreSQL 15 is a major release that includes new features and improvements over the previous version. Some of the most notable features in PostgreSQL 15 include:
- More efficient engine for full-text search
- More efficient replication protocol
- More efficient indexing algorithm
- More efficient foreign key constraint checking algorithm
- More efficient partitioning and distribution algorithm
- More efficient query planner
PostgreSQL server versions, Release Dates and EOL:
Version | Release Date | End of life |
15 | October 13, 2022 | November 11, 2027 |
14 | September 30, 2021 | November 12, 2026 |
13 | September 24, 2020 | November 13, 2025 |
12 | October 3, 2019 | November 14, 2024 |
11 | October 18, 2018 | November 9, 2023 |
10 | October 5, 2017 | November 10, 2022 |
Steps to install PostgreSQL 15 on Linux server
PostgreSQL 15 is available for download as ready-to-use packages or installers for various platforms. This guide will help you on how to install PostgreSQL 15 on Linux server.
If you are searching for PostgreSQL-14 installation then read this
Prerequisites:
- sudo privileges.
- Stable internet connection.
- Disable SELinux and Firewall.
First check server OS version then start installation as per OS version:
# egrep '^(VERSION|NAME)=' /etc/os-release
Installation on Red Hat family:
Steps to install PostgreSQL 15 on Red Hat Enterprise Linux, CentOS, Oracle Linux and Rocky Linux
First install PostgreSQL rpm repository:
For RHEL, CentOS and Oracle version 7
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
For RHEL, CentOS, Oracle and Rocky version 8
# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
For RHEL, CentOS, Oracle and Rocky version 9
# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Need to disable the built-in PostgreSQL module for OS version 8 and 9:
# dnf -qy module disable postgresql
Now install PostgreSQL 15 server:
For RHEL, CentOS and Oracle version 7
# yum install -y postgresql15-server
For RHEL, CentOS, Oracle and Rocky version 8 and 9
# dnf install -y postgresql15-server
Note : Fixing Failed to set locale, defaulting to C.UTF-8:
# dnf install langpacks-en glibc-all-langpacks -y
# localectl set-locale LANG=en_US.UTF-8
Initialize the database:
# /usr/pgsql-15/bin/postgresql-15-setup initdb
Installation on Debian family:
Steps to install latest PostgreSQL 15 on Debian and Ubuntu server.
Create the file repository configuration:
# 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
Now install the latest version of PostgreSQL:
Note: If you want a specific version, use ‘postgresql-13’ or similar instead of ‘postgresql’
# sudo apt-get -y install postgresql
Managing PostgreSQL service
let’s review some basic management commands.
Verify installed version of PostgreSQL:
# psql -V
Start the PostgreSQL service:
# systemctl start postgresql-15.service
Check status of the PostgreSQL service:
# systemctl status postgresql-15.service
Restart the PostgreSQL service:
# systemctl restart postgresql-15.service
If you want to reload PostgreSQL service to apply conf:
# systemctl reload postgresql-15.service
If you want to stop PostgreSQL service:
# systemctl stop postgresql-15.service
By default, PostgreSQL service is disabled to start automatically when the server boots. If you want to enable it at startup, run:
# systemctl enable postgresql-15.service
Re-disable the service to start up at boot:
# systemctl disable postgresql-15.service
Configure PostgreSQL:
Connect to a Local Database:
# sudo -u postgres psql
OR
# psql -h localhost -p 5432 -U postgres -d postgres
Connect to Remote Database:
If we want to connect from remote then we need to make changes in conf files
# sudo vim /var/lib/pgsql/15/data/pg_hba.conf
and add below line
host all all 0.0.0.0/0 md5
Then
# sudo vim /var/lib/pgsql/15/data/postgresql.conf
and edit below line
listen_addresses = '*'
# systemctl restart postgresql-15.service
# psql -h <database ip> -p 5432 -U postgres -d postgres
Create user and database:
postgres=# create database dbname;
postgres=# create user dbuser with encrypted password 'password';
postgres=# grant all privileges on database dbname to dbuser;
Check created database and user:
List database:
postgres=# \l
List user:
postgres=# \du
Connect to database:
postgres=# \c dbname
Uninstall PostgreSQL-15
To completely remove PostgreSQL 15 from a system, you must remove the PostgreSQL applications, the configuration files, and any directories containing data and logs.
Warning: This process will completely remove PostgreSQL, its configuration, and all databases. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.
Stop the PostgreSQL service first:
# systemctl stop postgresql-15.service
Remove any PostgreSQL packages that previously installed.
For RHEL / CentOS/ Oracle Linux / Rocky Linux / Amazon Linux
# yum erase $(rpm -qa | grep postgresql)
OR
# dnf erase $(rpm -qa | grep postgresql)
For Ubuntu / Debian
# apt autoremove --purge postgresql
Remove PostgreSQL databases and log files.
# rm -rf /var/lib/pgsql
# rm -rf /usr/pgsql-15
Congratulations! We’ve installed and configured PostgreSQL 15 database server on Linux system. We hope this 2 minutes guide helped you and thank you for visiting our website.
Cheers!!!