TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashCpanelLinux

How to enable password-less authentication for PostgreSQL user

We can configure the bash in such a way that it doesn't prompt for a password during PostgreSQL connections via psql.

This configuration can be done in two steps.

Step1: Open ".pgpass" file in home directory.

#vi ~/.pgpass

Step2: Save the following line to the file.

<host>:<port>:<database>:<user>:<password>

Where,

<host> need to be replaced with PostgreSQL host.
<port> need to be replaced with PostgreSQL port.
<database> need to be replaced with PostgreSQL database.
<user> need to be replaced with PostgreSQL username.
<password> need to be replaced with PostgreSQL password.

Now the psql command will login to the PostgreSQL shell without any arguments or prompts.

That's all…

Leave a Reply