Postgress task again failed

I have did all the things required and i am able to login to postgresql datadbase and i provided the all the permissions to the data base and made changes in pg_hbf.file but it is marked as failed.

FYI>>

Error : - ‘PostgreSQL’ is not configured correctly, either user ‘kodekloud_roy’ and database ‘kodekloud_db1’ does not exist or user ‘kodekloud_roy’ does not has appropriate permissions on database ‘kodekloud_db1’ on DB Server

Hello, @vishnu123sai
Strange. KKE team will look into it.
One more thing is have you encrypted given password into the md5sum?

yes, i encrypted. previously also i was failed. At least let me know the reason. so that i would correct mt self. but i did all the changes but failed :pensive:

hi @vishnu123sai, my task also failed for the second time.I believe, i have done it right. @Inderpreet or anyone else, Please take a look at the attached screenshot.Any help is much appreciated.Thanks.

The steps i have followed is as follows,
echo -n ‘provided password’ | md5sum
sudo -u postgres psql
CREATE USER kodekloud_pop WITH ENCRYPTED PASSWORD ‘d519eb4c9de1b2b69b2192a50a9fc408’;
CREATE DATABASE kodekloud_db6 OWNER kodekloud_pop;
GRANT ALL PRIVILEGES ON DATABASE kodekloud_db6 TO kodekloud_pop;
I have altered the user with SUPERUSER, CREATEDB, CREATEROLE
As per the screenshot, the user has all the necessary permissions as well as able to connect to database.


You don’t need to encrypt password into the md5. You have to use at it is from the question and you just need to configure method to accept md5 as you did. I haven’t seen in the question to convert into md5.

thanks @player001 for your response.I don’t think that is the reason why my task failed.

Regards
Nidhin

Below 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 --> Create user and db before restart

CREATE USER kodekloud_joy WITH ENCRYPTED PASSWORD 'B4zNgHA7Ya'; -> No need to used md5 password. uas given password as it is.

CREATE DATABASE kodekloud_db10 OWNER kodekloud_joy;

GRANT ALL PRIVILEGES ON DATABASE kodekloud_db10 TO kodekloud_joy;

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

except this i did everything same @selvag , But i don’t think that was mandatory, i am able to login into db without that change.

I have did all these changes what you mentioned but no luck, this time i am not able to login even.

hi @Inderpreet or admin,
if you get a chance, please take a look into this issue, so that I know where I went wrong.Thanks.

Regards
Nidhin

Hi Selvage, thanks for posting the solution.I have tried your steps, but I don’t see any roles attached to the user.Do I need to alter the user with SUPERUSER, CREATEDB, CREATEROLE command to see the permission?Also, when I try to login from postgres# using psql -U -d -h -W, nothing happens.Could you please guide me, what needs to be done to get it right.I am going to attempt this task third time.Thanks.
Regards
Nidhin

@nidhincn
below steps will give all permissions to user.

CREATE USER kodekloud_joy WITH ENCRYPTED PASSWORD 'B4zNgHA7Ya';
CREATE DATABASE kodekloud_db10 OWNER kodekloud_joy;
GRANT ALL PRIVILEGES ON DATABASE kodekloud_db10 TO kodekloud_joy;

reference : Install and Configure PostgreSQL -- failed

1 Like

Hi Selvag,
Finally, It worked for me in my third attempt and thank you for your prompt response, much appreciated.

Kind Regards
Nidhin

1 Like