Debian

How to Install PostgreSQL 14 on Debian 11

How to Install PostgreSQL 14 on Debian 11

PostgreSQL is also known as Postgres, an open-source and powerful objects-based relational database system that is used and combined with many features of SQL language. Using the Postgres database, you can easily store and scale the complicated data workload. Most of the mobile and web applications used the Postgres database for storing data. Postgres database can be installed on almost all operating systems including Linux.

We will go through the installation of Postgres or PostgreSQL 14 on the Debian 11 system using the command line method.

Prerequisites

  • Debian 11 Linux operating system with enough space should be running properly on your system.
  • You should have sudo privileges or must be login as a root user for installing the Postgres database on Debian 11 through the command line.

Installation of PostgreSQL on Debian 11

Follow the below-mentioned steps to install the Postgres or PostgreSQL14 on the Debian 11 system:

Step 1: Install Prerequisites

First, update the system repositories list using the ‘apt’ command.

$ sudo apt update

Now, install the recommended HTTPS support packages by executing the below-mentioned command:

$ sudo apt install -y curl apt-transport-https

Step 2: Add repository of PostgreSQL

By default, the PostgreSQL packages are not included in the Debian 11 repository. However, you can install the required packages by adding the PostgreSQL repository to your Debian system. So, download or import the signing key of the PostgreSQL repository by using the following command:

$ curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg

Add the PostgreSQL repository to your Debian 11 system by executing the below-mentioned command:

$ echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" | sudo tee /etc/apt/sources.list.d/postgresql.list

Step 3: Install PostgreSQL on Debian 11

Once the repository is included, install the PostgreSQL on Debian 11 system. The following syntax will help you to install the desired PostgreSQL version on your system:

$ sudo apt update

$ sudo apt install -y postgresql-version

Here, we are installing the latest PostgreSQL-14 on this system. Therefore, this command will be changed into the following order:

$ sudo apt install -y postgresql-14

The ‘-y’ option will allow you to ignore the confirmation prompt on your terminal window.

Once the Postgres installation is completed, the service of PostgreSQL will automatically start on your system.

Verify the ‘Active’ or excited status of Postgres service by running the below-mentioned command:

$ sudo systemctl status postgresql

If you did not receive the ‘Active’ status of the PostgreSQL service then, you can enable and start the PostgreSQL services by running the following command:

$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql

Once the postgreSQL installation is completed on your system, it creates by default a user with the name ‘Postgres’ that you can find in the /etc/passwd file.

$ cat /etc/passwd | grep -i postgres

Step 4: PostgreSQL server configurations

The postgreSQL listens at the localhost port ‘127.0.0.1’ by default. but, you change it with your system IP address.

$ sudo nano /etc/postgresql/14/main/postgresql.conf

Change the listen_addresses to your <IPAddress> or * symbol.

listen_addresses = 'IP-Address'

C:\Users\DELL\OneDrive\Desktop\qqq.png

Now, restart the postgreSQL service on your system.

$ sudo systemctl restart postgresql

Step 5: Login into the PostgreSQL database

Login as a ‘postgres’ user to the postgres database by using the below-mentioned command:

$ sudo -u postgres psql

Now, we can use the PostgreSQL database through the psql commands.

$ psql

Congratulations! We have successfully installed PostgreSQL 14 on the Debian 11 system. Now, you can easily create the postgreSQL databases on your system.

Conclusion

We installed PostgreSQL 14 database on the Debian 11 system. We have seen how to execute various commands to run the PostgreSQL-14 database on the Debian 11 system. The same installation steps you can follow to install the PostgreSQL on Ubuntu and its derivatives. You can also download the latest release notes for the installation of PostgreSQL 14 from its official PostgreSQL website. Thanks!

Similar Posts