As detailed in this blog post, there are two ways to non interactively provide a password to PostgreSQL utilities such as the pg _ dump command: using the. PGPASSWORD environment variable. Force pg _ dump to prompt for a password before connecting to a database. This option is never essential, since pg _ dump will automatically prompt for a password if the server demands password authentication. However, pg _ dump will waste a connection attempt finding out that the server wants a password.
Sign in Instantly share code, notes, and snippets. Let’s examine the options in more detail. U postgres: specifies the user to connect to PostgreSQL database server. We used postgres in this example. W: forces pg_dump to prompt for the password before connecting to the PostgreSQL database server.
After you hit enter, pg_dump will prompt for the password of postgres user. Updated to reflect changes from 8. If you have problems running pg_dump, make sure you are able to select information from the database using, for example, psql” To include the necessary DDL CREATE DATABASE command and a connection in the backup file, include the -C option. W: This option forces pg_dump to prompt for a password. This flag is not necessary since if the server. There are two ways to non interactively provide password for the psql command which is a PostgreSQL interactive terminal.
