Installation on GNU Linux
suggest changeOn most GNU+Linux operating systems, PostgreSQL can easily be installed using the operating system package manager.
Red Hat family
Repositories can be found here: https://yum.postgresql.org/repopackages.php
Download the repository to local machine with the command
yum -y install https://download.postgresql.org/pub/repos/yum/X.X/redhat/rhel-7-x86_64/pgdg-redhatXX-X.X-X.noarch.rpm
View available packages:
yum list available | grep postgres
Necessary packages are:
postgresqlXX
postgresqlXX-server
postgresqlXX-libs
postgresqlXX-contrib
These are installed with the following command: yum -y install postgresqlXX postgresqlXX-server postgresqlXX-libs postgresqlXX-contrib
Once installed you will need to start the database service as the service owner (Default is postgres). This is done with the pg_ctl command.
sudo -u postgres /usr/pgsql-X.X/bin/pg_ctl -D /var/lib/pgsql/X.X/data start
To access the DB in CLI enter psql
Debian family
On Debian and derived operating systems, type:
sudo apt-get install postgresql
This will install the PostgreSQL server package, at the default version offered by the operating system’s package repositories.
If the version that’s installed by default is not the one that you want, you can use the package manager to search for specific versions which may simultaneously be offered.
You can also use the apt repository provided by the PostgreSQL project (PGDG) to get a different version. The Debian and Ubuntu download page linked above has the repository setup. This may allow versions not yet offered by the operating system package repositories. The Yum repository is for Red Hat-family systems, not Debian.