Обсуждение: The .pgpass file

Поиск
Список
Период
Сортировка

The .pgpass file

От
Tommy Flewwelling
Дата:

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!

Re: The .pgpass file

От
Tom Lane
Дата:
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

Re: The .pgpass file

От
Peter Eisentraut
Дата:
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/

Re: The .pgpass file

От
Alvaro Herrera
Дата:
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