How to Install Postgresql on Centos 7

How to Install Postgresql on Centos 7


In this post I will share how to install PostgreSQL on Centos 7 with Official repository. First you nit edit repository configuration. In this tutorial I use nano, you need install nano first with run this command :

$ sudo yum install nano

then edit repository configuration

$ sudo nano /etc/yum.repos.d/CentOS-Base.repo

add this command to repository configuration

[base]

name=CentOS-$releasever - Base

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

exclude=postgresql*

#released updates

[updates]

name=CentOS-$releasever - Updates

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra

#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

exclude=postgresql*

Now, install a repository configuration package using the official PostgreSQL repository for CentOS:

sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y

after install PostgreSQL repository you can see all available and version with running this command

$ sudo yum list postgresql*

in this tutorial I will install PostgreSQL 11. to install PostgreSQL server use the following command :

$ sudo yum install postgresql11-server -y

now PostgreSQL is installed. You can create new database with following command below

$ sudo /usr/pgsql-11/bin/postgresql-11-setup initdb

now, start and enable PostgresSQL with command

$ sudo systemctl start postgresql-11

$ sudo systemctl enable postgresql-11

install PostgresSQL done, you need to config postgresql.conf and pg_hba.conf for access this database. I will share in next tutorial how to access this PostgreSQL from GUI with datatables for Linux. Thanks :)


Post a Comment

Previous Post Next Post