pg_dump password authentication failed error with pgpass.conf file in Windows
<p>I couldn't do a backup because pg_dump shows the following error. </p>

<pre><code>pg_dump: [archiver (db)] connection to database "mydb" failed: 
FATAL:  password   authentication failed for user "postgres"
password retrieved from file 
"C:\Users\MyName\AppData\Roaming\postgresql\pgpass.conf"
</code></pre>

<p>This is what my pgpass file look like. </p>

<pre><code>localhost:5432:mydb:postgres:mypassword
</code></pre>

<p>When I remove pgpass.conf file and run the pg_dump file, it prompts for password and the backup runs properly. </p>

<p>This is what the pg_dump script looks like. </p>

<pre><code>set PGPASSFILE=%APPDATA%\postgresql\pgpass.conf
%PG_BIN%pg_dump -h %PG_HOST% -p %PG_PORT% -U %PG_USER% -F c -b -v -f %BACKUP_FILE% %DB%
</code></pre>

<p>This is a Windows scheduled task so I don't want the user to enter the password. </p>