Install and Configure PostgreSQL

Same issue faced … Hope someone could assist and fix.

Hi @kleansoul, in the screenshot you are using the -W switch to connect to the DB, which forces psql to prompt for a password before connecting to a database. Did you enable md5 authentication for the user by changing the configuration in file /var/lib/pgsql/12/data/pg_hba.conf ?


Whats wrong with my task resolution

a. Install and configure PostgreSQL database on Nautilus database server.

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

b. Create a database user kodekloud_aim and set its password to GyQkFRVNr3.

echo -n 'GyQkFRVNr3' | md5sum

su - postgres
psql=# CREATE USER kodekloud_aim WITH ENCRYPTED PASSWORD 'md520c59d9fe9be7db32e683554222f227c';
psql=# CREATE DATABASE kodekloud_db9 OWNER kodekloud_aim;

c. Create a database kodekloud_db9 and grant full permissions to
user kodekloud_aim on this database.

psql=# GRANT ALL PRIVILEGES ON DATABASE kodekloud_db9 TO kodekloud_aim;

d. Make appropriate settings to allow all local clients to
connect to the kodekloud_db9 database through kodekloud_db9
user using md5 encrypted password for authentication.

edit pg_hba.conf to use md5 and change all to kodekloud_db9
edit postgresql.conf to permit listen = localhost

systemctl restart postgresql.service
systemctl status postgresql.service

e. At the end its good to test the db connection using these new
credentials from root user or server’s sudo user.

try to connect psql using root does not work
    psql -U root -h localhost -d kodekloud_db9 -W 

Connect using kodekloud_aim 
    psql -U kodekloud_aim -d kodekloud_db9 -h -W

Works OK

@kleansoul did you also test it with -h localhost ?

Yes, and it worked with that too.

Thats why I was surprised why the task got failed.

what is your email ID?

Hi @Inderpreet,

The task has also been marked failed for me though I was able to authenticate with password using the kodekloud_roy user to database kodekloud_db8 as described in the task. The error is saying the user or the database does not exist, please check.

Please check. Thank you!


Did you got time to check?

Hi @Inderpreet

Havnt received any reply from you yet on that task ??

Have you checked and marked it correctly please.

@kleansoul Sorry for delayed response. There were some missing config changes in your hba conf. Did you enable the local all connections ? As mentioned in last point of question you could test by login into Linux root user or sudo user and then by accessing the DB using credentials you created.

@Inderpreet Thanks for your response. Though this has now been almost more than a week old task but you can check my screenshots on the below link and see that the I tested the login and it worked fine also. I suspect some other platform related issue as that week there were lot of ongoing issues with labs (if you remember, for which it was reported too several times on slack).



As per your screenshot when you tested the access you were logged in to kodekloud_roy user itself which worked, however as asked in the question it must work for all local clients so you could tested while switching to root or sudo user. Also the reply given on this thread is the correct way to configure as per requirements

  1. The password doesn’t need to be hashed in order to finish the task successfully.
    So like this:
  2. /var/lib/pgsql/data/pg_hba.conf needs just to edited like this:
    “local” is for Unix domain socket connections only
    local all all md5
  3. Just test the connection with the root user and the Task password:
    [root@stdb01 ~]# psql -U kodekloud_aim -d kodekloud_db2
    Password for user kodekloud_aim:
    psql (9.2.24)
    Type “help” for help.


And the Task should be successful.

hi @dipjyoty
what do task 4 and 5 check?

1 Like

@swaroopcs88 please check your inbox.