Installation configuration and use of CentOS7 PostgreSQL

  • 2020-05-27 07:46:06
  • OfStack

CentOS7 PostgreSQL installation

Install

The installation

Install using yum

yum install http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
yum install postgresql94-server postgresql94-contrib

Set to boot

systemctl enable postgresql-9.4.service
systemctl start postgresql-9.4.service

Initialize the database

/usr/pgsql-9.4/bin/postgresql94-setup initdb

Enable remote access

/var/lib/pgsql/9.4/data/postgresql.conf

listen_addresses ='*'

/var/lib/pgsql/9.4/data/pg_hba.conf


# IPv4 local connections:
host  all       all       127.0.0.1/32      trust
host  all       all       192.168.117.1/32    trust
# IPv6 local connections:
host  all       all       ::1/128         trust

Change user password


su postgres
psql -U postgres
ALTER USER postgres WITH PASSWORD 'P0stgres'
\q

A firewall

New file/usr/lib/firewalld/services/postgres94 xml


<?xml version="1.0" encoding="utf-8"?>
<service>
    <short>Postgres 9.4 Database service</short>
    <description>Postgres</description>
    <portprotocol="tcp"port="5432"/>
</service>

Modify firewall Settings


firewall-cmd --permanent --add-service=postgres94
firewall-cmd --reload

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: