Install and Configure PostgreSQL Kodekloud

 


Question:


Solution:

Login to database server

ssh peter@stdb01

Then login as root

sudo su

Then install postgresql

yum install postgresql-server postgresql-contrib
postgresql-setup initdb
systemctl enable postgresql && sudo systemctl start postgresql
systemctl status postgresql

Enter into postgresql database

sudo -u postgres psql postgres

Create user, database, and grant permission


CREATE USER kodekloud_aim WITH PASSWORD 'dCV3szSGNA';
CREATE DATABASE kodekloud_db8;
GRANT ALL PRIVILEGES ON DATABASE "kodekloud_db8" to kodekloud_aim;

Then set the config for local

sudo vi /var/lib/pgsql/data/pg_hba.conf

Go to bottom of the config and edit

local all all md5

host all all 127.0.0.1/32 md5 

Next open another config

sudo vi /var/lib/pgsql/data/postgresql.conf

Uncomment listen_address=localhost

Then restart
sudo systemctl restart postgresql
sudo systemctl status postgresql.service

Finally Check

psql -U kodekloud_aim -d kodekloud_db8 -h 127.0.0.1 -W

psql -U kodekloud_tim -d kodekloud_db8 -h localhost -W


Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

1 comments:

  1. Hi Shawaon,

    thanks you for the blog.

    would you please explain the below config?
    local all all md5

    host all all 127.0.0.1/32 md5

    Couldnt get the difference between host and local

    ReplyDelete