If you take a close look at the connection parameters shown in the previous section, you will notice that there is no way to pass a password to pg_dump. You can enforce a password prompt, but you cannot pass the parameter to pg_dump using a command-line option.
The reason for this is simply because the password might show up in the process table and be visible to other people. The question now is: if pg_hba.conf, which is on the server, enforces a password, how can the client program provide it?
There are various means of doing this. Here are three:
- Making use of environment variables
- Making use of .pgpass
- Using service files
In this section, we will learn about all three methods.