Posted - Feb 12 2013 : 6:47:48 PM
| I want to get DDL for a postgresql database. pg_dump.exe is not working. I think it's a password issue. How do I specify the password to pg_dump.exe?
From what I understand of pg_dump.exe, you can't pass a password on the cmd line. From the pgsql docs I found this on the pg_dump.exe page:
"If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail."
This is likely the case you are dealing with. The workaround appears to be to specify password in the "pgpass" file. So here is the documentation on the pgpass file:
I think to get this working, you need to add a line to pgpass.conf for the user you are connecting as in your pgsql connection string. Just for reference, here are the contents of my pgpass.conf file on the system I have been using for testing this. I always have been connecting as the user "postgres"
On my system, this file is located here: C:\Users\Jesse\AppData\Roaming\postgresql
Note that if you have the PGPASSWORD environment variable set, it may override whatever you have set in the .pgpass file. Use of PGPASSWORD env var is not recommended. More on env vars here: http://www.postgresql.org/docs/9.1/static/libpq-envars.html