How to Install PostgreSQL on Linux Mint 20

To Install PostgreSQL on Linux Mint 20

Introduction:

PostgreSQL is the most advanced, powerful open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. This tutorial will cover the installation of PostgreSQL on Linux Mint 20. Installation Procedure: First I am check the version of my linux mint version by using following command

root@LinuxHelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20
Release:	20
Codename:	ulyana

Now I am import the GPG key of PostgresSQL by using following command

root@LinuxHelp:~# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
OK

Now I am add the postgres repository by using following command

root@LinuxHelp:~# sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

Now I am install postgresSQL by using following command

root@LinuxHelp:~# apt install postgresql postgresql-contrib -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libllvm10 libpq5 postgresql-12 postgresql-client-12 postgresql-client-common
  postgresql-common sysstat
Suggested packages:
.
.
Processing triggers for systemd (245.4-4ubuntu3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for doc-base (0.10.9) ...
Processing 1 added doc-base file...

Now I am switch the postgres user by using following command

root@LinuxHelp:~# su postgres

Now I am check the version of the postgres by using following command

postgres@LinuxHelp:~$ psql
psql (12.5 (Ubuntu 12.5-0ubuntu0.20.04.1))
Type "help" for help.

Now I am view the information of the postgres database by using following command

postgres=# \conninfo

You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".

Now I am exit from the postgres shell

postgres=# exit

now I am check the listening port of postgres by using following command

postgres@LinuxHelp:~$ ss -atulpn | grep postgres
tcp     LISTEN   0        244            127.0.0.1:5432           0.0.0.0:*      users:(("postgres",pid=5592,fd=3))  

With this method the installation of the PostgreSQl on Linux Mint 20 is comes to an end.

FAQ
Q
How do you add the repository on PostgreSQL?
A
By using following command to add the repository on postgreSQL
#sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
Q
What are the features of PostgreSQL?
A
Complex SQL queries
SQL Subselects
Foreign Keys
Trigger views
Transactions
Multiversion currency COntrol
Streaming Replication
Hot Standby
Q
How do you check the listening ports on Postgres?
A
by using the following command to check the listening ports of postgre
#ss -atulpn | grep postgres
Q
How do add the key for PostgreSQL?
A
by using the following command to add the key
#wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Q
What is the use of PostgreSQL?
A
PostgreSQL is a general-purpose object-relational database management system. It allows users to add custom functions
developed using different programming languages such as C/C++, Java, etc.