Postgres - Install and Configure

local all all md5
credentials that you have to set to local clients are able to access the database.

@Tej-Singh-Rana how about the ip range not required ?

@kaushik task is about local clients so where we need ip address.
add local all all md5
here is the solution of your questions
Hope it will help you to understand your query.
thanks,

1 Like

Hi @Inderpreet, I also had this problem even I have installed and configured Postgresql as required but it shows the task as failure.



Please check the below steps which I performed during the installation and configuring the PostgreSQL

  1. sudo yum install postgresql-server postgresql-contrib
  2. sudo postgresql-setup initdb
  3. sudo systemctl enable postgresql && sudo systemctl start postgresql
  4. echo -n ‘BruCStnMT5’ | md5sum
  5. sudo -u postgres psql postgres
  6. CREATE USER kodekloud_joy WITH ENCRYPTED PASSWORD ‘1de08cde294b11aa10e2d39b30286c95’;
  7. CREATE DATABASE kodekloud_db3 OWNER kodekloud_joy;
  8. GRANT ALL PRIVILEGES ON DATABASE kodekloud_db3 TO kodekloud_joy;
  9. sudo vi /var/lib/pgsql/data/pg_hba.conf
  10. sudo vi /var/lib/pgsql/data/postgresql.conf
  11. sudo systemctl restart postgresql.service
  12. psql -U kodekloud_joy -d kodekloud_db3 -h 127.0.0.1 -W

Can you please check ?

@fazalmahmood this is marked Success for you.

I am having the same issue. Anyone please help me.
@Inderpreet @Tej-Singh-Rana @mmumshad @fazalmahmood.

I did the same process as you described @fazalmahmood but it shows failed login with error message as "psql: FATAL: password authentication failed for user “kodekloud_user” . There is one thing I need to know that what to write in “postgresql.conf” and “pg_hba.conf” files or what else I need to change in the process @mmumshad @Inderpreet @Tej-Singh-Rana @kaushik .

Already described there compare with your pg_hba.conf file. You have to setup connection for local and authentication with md5 encrypted password so change peer to md5.

@rakshita I think you made mistake here
echo -n ‘BruCStnMT5’ | md5sum

you should replace BruCStnMT5 with your password as mentioned in your task and use the md5 output in following command

CREATE USER “KODEKLOUD_USER_HERE” WITH ENCRYPTED PASSWORD ‘YOUR_MD5_WILL_BE_HERE’;

and uncomment “listen_addresses” in postgresql.conf and replace existing Method with md5 in pg_hba.conf

Hope It’ll work for you

I have used my password only. And did all the configurations as you mentioned. Still not working???
@fazalmahmood

You don’t need to convert the password into md5.

I performed the whole task in right way but still unable to login to user and resulted in task failure.
Please check @Inderpreet @mmumshad @Tej-Singh-Rana @fazalmahmood @kaushik.
Screenshot (306)|690x210

@rakshita Change method from ident to md5 in IPv4 local connections, below line where you changed previously

Hi,

facing same Issue. Did all Tasks as written and double check that i can login with the User but marked as failed:

image

What did i wrong here?

@Inderpreet could you check what i did wrong, its a 600 Point Task so i feel sad to fail it

Hello, martin
What you have configured in pg_hba.conf file?

Hi player001,

i specified local kodekloud_db3 kodekloud_joy md5 and the same for host.
I dont understand where the failure is as you see in my screenshot it worked as it should.

Kind Regards,
Martin

Tag to inderpreet. He will be verify your process.

1 Like

@Inderpreet @Tej-Singh-Rana @devops503 @fazalmahmood @juancgarciaco
Getting below error, please guys help me out to complete the task!

Steps Followed:

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

echo -n ‘BruCStnMT5’ | md5sum
184b4fb9d4689f4acc81eaafe9d9cf2ad

su - postgres
sudo -u postgres psql postgres
psql
psql=# CREATE USER kodekloud_tim WITH ENCRYPTED PASSWORD ‘184b4fb9d4689f4acc81eaafe9d9cf2ad’;
psql=# CREATE DATABASE kodekloud_db8 OWNER kodekloud_tim;

psql=# GRANT ALL PRIVILEGES ON DATABASE kodekloud_db8 TO kodekloud_tim;

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

local all all md5
host kodekloud_db8 kodekloud_tim 127.0.0.1/32 md5
host kodekloud_db8 kodekloud_tim ::1/128 md5

vi /var/lib/pgsql/data/postgresql.conf
listen_addresses= ‘*’

systemctl restart postgresql.service
systemctl status postgresql.service

#Authentication
psql -U kodekloud_tim -d kodekloud_db8 -h 127.0.0.1 -W

Please check and let me know what else change can be done to complete the task!

Removed md5 encryption and worked!

CREATE USER kodekloud_aim WITH ENCRYPTED PASSWORD ‘TmPcZjtRQx’;

this worked for me :smiley:

Thanks @nenadmiladin for your post on the task, helped me to complete the task!

2 Likes

Solution for the beginners: Install and Configure PostgreSQL Kodekloud