Install and Configure PostgreSQL -- failed

Install and Configure PostgreSQL - Failed.

Please check my steps and let me know what was wrong.
psql=# CREATE USER kodekloud_sam WITH ENCRYPTED PASSWORD ’ forgot_result_of_md5’;
psql=# CREATE DATABASE kodekloud_db5 OWNER kodekloud_sam;
psql=# GRANT ALL PRIVILEGES ON DATABASE kodekloud_db5 TO kodekloud_sam;

1 2

1 Like

@asomiddin this is marked success for you.

Thanks @asomiddin .

Bellow steps worked for me

sudo yum install postgresql-server postgresql-contrib

sudo postgresql-setup initdb

systemctl enable postgresql && systemctl start postgresql

sudo -u postgres psql

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

listen_addresses = 'localhost' # what IP address(es) to listen on

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

Change all to md5

host all all 0.0.0.0/0 md5

sudo systemctl restart postgresql

To validate try to login with password like below

sudo -u postgres psql

psql -U kodekloud_joy -d kodekloud_db10 -h 127.0.0.1 -W

psql -U kodekloud_joy -d kodekloud_db10 -h localhost -W

sudo -i

psql -U kodekloud_joy -d kodekloud_db10 -h 127.0.0.1 -W
psql -U kodekloud_joy -d kodekloud_db10 -h localhost -W