Install PostgreSQL on CentOS.
dnf -y install postgresql-server postgresql-contrib
Initiate DB setup.
postgresql-setup initdb
Start and enable PostgreSQL.
systemctl start postgresql && systemctl enable postgresql
login to db using psql.
psql -U postgres
Create user.
CREATE ROLE kodekloud_sam WITH
LOGIN
PASSWORD 'Rc5C9EyvbU';
Create database.
CREATE DATABASE kodekloud_db7;
Verify.
\du # All users
\du kodekloud_sam # Single user info
Add privilleges to the user.
GRANT ALL PRIVILEGES ON DATABASE kodekloud_db7 TO kodekloud_sam;
Edit another config file /var/lib/pgsql/data/pg_hba.conf & configure the md5.
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Verify.
psql -U kodekloud_top -d kodekloud_db7 -h 127.0.0.1 -W