1、Install the repository RPM:
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
2、Install the client packages:
yum install postgresql95
3、Optionally install the server packages:
yum install postgresql95-server
4、Optionally initialize the database and enable automatic start:
/usr/pgsql-9.5/bin/postgresql95-setup initdb
systemctl enable postgresql-9.5
systemctl start postgresql-9.5
5、Test:
su - postgres
$ psql
$\l
CREATE DATABASE myDb;
CREATE USER mytest CREATEDB LOGIN PASSWORD 'mytest';
GRANT ALL ON DATABASE myDb TO mytest;