The .pgpass file

Started by Tommy Flewwellingover 18 years ago4 messagesgeneral
Jump to latest
#1Tommy Flewwelling
tommyflewwelling@hotmail.com

Hello,

How do I specify in the command-line to access the .pgpass file when creating a database?

I would like to use ~/.pgpass instead of –W on the command line when creating a database (createdb) and was wondering the correct syntax.

For example,

I don’t want to have to include (-W):
C:\postgressql\bin>createdb -U postgres –p 5432 -W –E UTF8 myDatabase

and substitute it for ~/.pgpass or PGPASSFILE:

C:\postgressql\bin>createdb -U postgres –p 5432 ~/.pgpass –E UTF8 myDatabase

How do I inform the complier to extract the password from the file and not the prompt the user?

Any suggestions would be greatly appreciated.

Tommy_
_________________________________________________________________
R U Ready for Windows Live Messenger Beta 8.5? Try it today!
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tommy Flewwelling (#1)
Re: The .pgpass file

Tommy Flewwelling <tommyflewwelling@hotmail.com> writes:

How do I specify in the command-line to access the .pgpass file when creating a database?

Huh? You don't specify anything, it's done automatically when needed.

I don�t want to have to include (-W):
C:\postgressql\bin>createdb -U postgres �p 5432 -W �E UTF8 myDatabase

You never have to include -W, whether you use .pgpass or not. That
switch is only there for historical reasons.

regards, tom lane

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Tommy Flewwelling (#1)
Re: The .pgpass file

Am Mittwoch, 7. November 2007 schrieb Tommy Flewwelling:

How do I inform the complier to extract the password from the file and not
the prompt the user?

It does that automatically. Just omit the -W option.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tommy Flewwelling (#1)
Re: The .pgpass file

Tommy Flewwelling wrote:

Hello,

How do I specify in the command-line to access the .pgpass file when
creating a database?

You don't. If the file exists and has the correct permission, createdb
will read it. If the needed password is found, the connection will be
done without ever prompting the user.

FWIW the -W switch is useless. If createdb finds that the password is
needed, it will prompt the user even if -W is not specified. If
createdb finds that the password is not needed, then it won't prompt the
user.

(Note that none of this is actually createdb's feature. It is all done
by libpq internally.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support