PostgreSQL Server Installation on Linux 8

PostgreSQL is a powerful, open-source database system known for its strength and ability to grow with your needs. It supports many data types and advanced features, such as complex queries and triggers. PostgreSQL is very flexible, letting you create your own data types and operators. It follows SQL standards closely and ensures data reliability with ACID transactions. With a large community, PostgreSQL keeps improving and offers plenty of help and tools for users.

Mount Linux Media and Link Yum Repository either on Internet or locally.

Stop Fire wall and disable SELinux
service firewalld stop
setenforce 0
vi /etc/sysconfig/selinux
SELINUX=enforcing

Create Directory for Database Files
mkdir -p /u01/data
chown -R postgres:postgres /u01/data
chmod 777 /u01/data

Installing PostgreSQL RPM from mounted Linux Media
sudo dnf install postgresql-server postgresql-contrib -y

Replace Database Directory Path in below PostgreSQL File
vi /lib/systemd/system/postgresql.service
Environment=PGDATA=/u01/data

Initialize PostgreSQL Database
/usr/bin/postgresql-setup --initdb

Connection : Specifies the TCP/IP address(es) on which the server is to listen for connections from Client Applications (List IP Address for Allow)
vi /u01/data/postgresql.conf
listen_addresses = '*'

it only matches connection attempts made over TCP/IP that do not use SSL (hostnossl database user address auth-method)
vi /u01/data/pg_hba.conf
hostnossl all all 0.0.0.0/0 trust

Start and Enable PostgreSQL Services
systemctl start postgresql
systemctl enable postgresql

Change Password of Postgre User
sudo -i -u postgres
psql
\password postgres
\q

Create Database and User in PostgreSQL
psql
create database Inventory;
CREATE USER kamran WITH PASSWORD 'kamran';
GRANT ALL PRIVILEGES ON DATABASE inventory TO kamran;
\q

Check PostgreSQL Configuration Parameters
SHOW config_file;

Check Database Directory of PostgreSQL
SHOW data_directory;
\q