PostgreSQL is a cross-platform relational database management system (DBMS) which is also known as Postgres. It is a free and open-source DBMS and it supports multiple operating systems including Linux, macOS, and Windows. This DBMS allows those transactions that have ACID properties i.e. Atomicity, Consistency, Isolation, and Durability. Today, we will show you the method of installing this relational DBMS on the Linux operating system.
Note: For installing PostgreSQL on Linux, we have used Linux Mint 20.
Method of Installing PostgreSQL:
For having PostgreSQL installed on your Linux Mint 20 system, you are required to follow all the steps stated below:
Step # 1: Updating and Upgrading the Linux Mint 20 System:
For updating your Linux Mint 20 system, you should run the following command after launching the terminal by clicking on its shortcut icon:
sudo apt update
Once your system has updated all the necessary packages and dependencies, you will see the output shown in the image below on your terminal:
Now it is the turn to upgrade your Linux Mint 20 system by running the following command in the terminal:
sudo apt upgrade
The up-gradation process will take a sufficient time to complete after which you will see the output shown in the image below on your terminal:
Step # 2: Installing PostgreSQL on Linux Mint 20:
Once our Linux Mint 20 system has been successfully updated and upgraded, we are all set to install on it by running the following command in the terminal:
sudo apt install postgresql
During the execution of this command, as soon as you will be prompted to provide your confirmation, then do this by typing in “Y” for carrying on smoothly with your installation as highlighted in the image shown below:
Once a PostgreSQL has been successfully installed on your Linux Mint 20 system, your system will cause the terminal to display the output shown in the image below:
Step # 3: Checking the Status of PostgreSQL:
Before accessing the PostgreSQL console, we need to verify whether this service is active or not by checking its status. The status can be checked by running the following command in the terminal:
sudo systemctl status postgresql
Running this command will display the status as highlighted in the image shown below. With this, you can verify that the PostgreSQL server is active. However, it will not be running, instead, it will show the “exited” status which means that you need to log in to the server.
Step # 4: Logging in to the PostgreSQL Server:
For accessing the console, we first need to log in to the PostgreSQL server by running the following command in our terminal:
sudo –i –u postgres
When you will run this command, you will immediately be logged into the server.
Step # 5: Accessing the PostgreSQL Console:
Now for accessing the console, we will run the command stated below while being logged in to the PostgreSQL server:
Running this command will take us straight to the console as shown in the following image:
You can exit from the console at any time by typing “\q” in this console and then pressing the Enter key as highlighted in the image shown below:
By going through all the steps listed in this article, you can easily have PostgreSQL installed on your Linux Mint 20 system and hence you can use it for efficiently managing your relational databases.