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
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 Fedora, CentOS, RedHat with Yum
dnf based distros postgresql is named as
postgresql-server . We can show detailed packages information like version, arch, size release by using
$ yum info postgresql-server
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
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.
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
than we will start the setup process by running downloaded file with root privileges by using
$ chmod u+x
$ sudo ./postgresql-10.1-3-linux-x64.run
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
$ sudo /usr/bin/postgresql-setup --initdb
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 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