How To Install PostgreSQL Server Into Linux, Debian, Ubuntu, CentOS, Mint, Fedora, Redhat? – POFTUT

How To Install PostgreSQL Server Into Linux, Debian, Ubuntu, CentOS, Mint, Fedora, Redhat?


PostgreSQL is very popular open source database. It is used by big companies like Google, Facebook etc. PostgreSQL can be used without a cost. In this tutorial we will look how to install PostgreSQL into Linux distributions like Debian, Ubuntu, Mint, Fedora, CentOS, RedHat by using different ways like package management or downloading setup file.

Show PostgreSQL Package Version For Ubuntu, Debian, Mint, Kali with Apt

In apt-get  or apt based distros the postgresql server is named as postgresql . We can print and show package related information with  show option. This will list information like version, section, download size, installed size.

$ apt show postgresql
Show PostgreSQL Package Version For Ubuntu, Debian, Mint, Kali with Apt
Show PostgreSQL Package Version For Ubuntu, Debian, Mint, Kali with Apt

Show PostgreSQL Package Version For Fedora, CentOS, RedHat with Yum

In yum  or dnf based distros postgresql is named as postgresql-server . We can show detailed packages information like version, arch, size release by using info option.

$ yum info postgresql-server
Show PostgreSQL Package Version For Fedora, CentOS, RedHat with Yum
Show PostgreSQL Package Version For Fedora, CentOS, RedHat with Yum

Install PostgreSQL Package Version For Ubuntu, Debian, Mint, Kali with Apt

Now we can install related postgresql package as we have enough information about the package. We will use install  option in order to install postgresql server. We will also provide -y to automatically accept questions about installation.

$ sudo apt install postgresql -y

Install PostgreSQL Package Version For Fedora, CentOS, RedHat with Yum

We will use yum  or dnf package manager for rpm type. We will use install  option and provide the postgre sql package name which is postgresql-server . We will also provide -y in order to automatically accept asked questions.

$ sudo dnf install -y postgresql-server

Install With Setup File For All Linux Versions

We have option to installe PostgreSQL Server from binary without using package manager. The adventage of using setup file is getting the latest version of the PostgreSQL Server. But the downside is there may be some incompabilities with the current distribution. We can download the binary setup file from link below.

LEARN MORE  Redis Tutorial

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads#linux

In this case we will download version 10.1 which link is below.

$ wget https://get.enterprisedb.com/postgresql/postgresql-10.1-3-linux-x64.run
Install With Setup File For All Linux Versions
Install With Setup File For All Linux Versions

than we will start the setup process by running downloaded file with root privileges by using sudo.

$ chmod u+x 
$ sudo ./postgresql-10.1-3-linux-x64.run

Initialize Database

Before starting to use database server we need to initilize the database. We will use postgresql-setup tool. We will provide the --initdb  option which will database directory /var/lib/pqsql/data and /varlib/pgsql/initdb_postgresql.log .

$ sudo /usr/bin/postgresql-setup --initdb
Initialize Database
Initialize Database

Start PostgreSQL Database Service

Now we can start our PostgreSQL Database service. We will use systemctl start  command for this. The PostgreSQL service is named as postgresql.service . We also need root privileges where we will provide with sudo .

$ sudo systemctl start postgresql.service

Check PostgreSQL Database Service Status

Now everything seems ok but we need to the the service status to be sure. We will use systemctl status  command with the postgresql service name.

$ sudo systemctl status postgresql.service
Check PostgreSQL Database Service Status
Check PostgreSQL Database Service Status

1 thought on “How To Install PostgreSQL Server Into Linux, Debian, Ubuntu, CentOS, Mint, Fedora, Redhat?”

Leave a Comment