PostgreSQL: Why psql is running without Password?

I have configured one of my PostgreSQL Test Server in windows operating system.

I just open psql command line tool and it opened without asking a any password.

I just surprised, when I logged in psql without any password. This should not happen in any situation.

I was finding a solution of this problem and came to know about pgpass.conf file for Windows OS and .pgpass file for Unix OS.

This file exists on client location and contain information about login authentication.

For windows, you can find this file here: %APPDATA%\postgresql\pgpass.conf

The format of this file:

I have opened this file in windows and found that password written in plain text.
Whenever I open psql, it takes default postgres user password from this file.

I just removed this plain text password from pgpass.conf file and now psql prompts to enter a specific password for login.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from