Install Postgresql13 on RHEL7
1 min readDec 24, 2020
- Install the repository RPM
$sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2. Install PostgreSQL
$sudo yum install -y postgresql13-server
3. Optionally initialize the database and enable automatic start
$sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
$sudo systemctl enable postgresql-13
$sudo systemctl start postgresql-13
$sudo systemctl status postgresql-13
4. set password to the os user ‘postgres’ created by default
#passwd postgres
5. change password of db role ‘postgres’ created by default
#su - postgres
$psql
postgres=#\password postgres
postgres=#\q
6. Permit login to database through username and password instead of peer.
#vim /var/lib/pgsql/13/data/pg_hba.conf# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections only
local all all scram-sha-256
# IPv4 local connections:
host all all 0.0.0.0/0 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
7. Allow postgresql-server to listen all ip address
#vim /var/lib/pgsql/13/data/postgresql.conf
listen_address='*'
8. Restart services and check the version
#systemctl restart postgresql-13
$psql -V