×



PostgreSQL is a popular household name amongst database administrators and developers. It is a powerful and opensource Relational Database Management System ( RDBMS ) that leverages the SQL query language to create and manipulate databases. With over 30 years of active development, PostgreSQL is widely used as a database for numerous mobile and web applications. Some of the notable Tech giants that use PostgreSQL include Instagram, Uber, Spotify, and Reddit.

PostgreSQL 13 is the current stable version of PostgreSQL. It ships with new features including incremental sorting, parallel vacuuming and optimizations such as better data management for big or small workloads and security enhancements. Some of its features are: ACID transactions, foreign keys, views, sequences, subqueries, triggers, user-defined types and functions, outer joins, multiversion concurrency control, Graphical user interfaces and bindings for many.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related PostgreSQL queries.

In this context, we shall look into the installation procedure of PostgreSQL 13 on Debian 11.

In a previous post, we discussed how to install PostgreSQL 13 on Rocky Linux 8.


Steps to Install PostgreSQL 13 on Debian 

Before proceeding with this Installation procedure, ensure you have an Debian 11 server instance with SSH access and a sudo user already configured for executing privileged tasks. Then follow the below process.


1. Install PostgreSQL 13

By default, the latest version of PostgreSQL – PostgreSQL 13 – is hosted on Debian repository. To confirm this, simply run the below command:

$ apt-cache postgresql

Therefore, to install PostgreSQL 13, first update Debian 11 package index:

$ sudo apt update

Thereafter, use the APT package manager to install PostgreSQL 13 alongside other additional packages and dependencies:

$ sudo apt install postgresql postgresql-contrib

This installs PostgreSQL, and additional software packages and their dependencies.


2. Confirm the status of PostgreSQL 13

The PostgreSQL database service should start automatically without intervention. Verify this with the below command:

$ sudo systemctl status postgresql@13-main.service

If you are curious enough, you can check the version installed as follows:

$ /usr/lib/postgresql/bin/postgres -V


3. Start and enable PostgreSQL 13

If by any chance PostgreSQL is not running or is inactive, you can start it using the command:

$ sudo systemctl start postgresql@13-main.service

To make PostgreSQL automatically start every time the system is powered on or rebooted, enable it with the below command:

$ sudo systemctl enable postgresql@13-main.service


4. Access PostgreSQL 13 database server

When PostgreSQL is installed, a new user called postgres is created by default. You can confirm this by having a peek at the /etc/passwd file which stores user's information such as UID and GID:

$ cat /etc/passwd | grep -i postgres

To make matters simpler, you can invoke the id command:

$ id postgres

To connect to the database, switch to the postgres user with the below command:

$ sudo su - postgres

Then access the PostgreSQL interactive shell, run:

$ psql

The interactive shell allows you to run SQL queries and perform all matter of SQL queries. Run the help command to view some command usages:

postgres=# help

To exit the shell, simply run:

# \q

Then exit from the postgres user session:

$ exit


[Need assistance in configuring Open Source Software on Linux systems? We can help you. ]


Conclusion


More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com