dbTalk Databases Forums  

passing password to psql, pg_restore etc.?

comp.databases.postgresql comp.databases.postgresql


Discuss passing password to psql, pg_restore etc.? in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Skeptik
 
Posts: n/a

Default passing password to psql, pg_restore etc.? - 04-10-2008 , 11:39 AM






Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

psql -h localhost -p 5432 -U postgres -f MONITORINGZ_GLOBALS.sql
createdb -h localhost -p 5432 -U postgres -E UTF8 -O monitoringz
MONITORINGZ
pg_restore.exe -i -h localhost -p 5432 -U postgres -d "MONITORINGZ" -s -v
"MONITORINGZ.backup"

By the way, I am not concerned about security in this case...

Thanks.



Reply With Quote
  #2  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM






Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #3  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #4  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #5  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #6  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #7  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #8  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #9  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 12:59 AM



Skeptik schrieb:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

If you DB is on a unix machine and you connect from this machine,
you can use this line in pg_hba.conf:

local all all ident sameuser

This allows access without password if the db-username matches
the unix username.

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


Reply With Quote
  #10  
Old   
Piotr Szwed
 
Posts: n/a

Default Re: passing password to psql, pg_restore etc.? - 04-11-2008 , 08:14 AM



Skeptik pisze:
Quote:
Hello.
How to pass password in these commands, without beeing prompted, and
without pgpass.conf?

psql -h localhost -p 5432 -U postgres -f MONITORINGZ_GLOBALS.sql
createdb -h localhost -p 5432 -U postgres -E UTF8 -O monitoringz
MONITORINGZ
pg_restore.exe -i -h localhost -p 5432 -U postgres -d "MONITORINGZ" -s -v
"MONITORINGZ.backup"

By the way, I am not concerned about security in this case...

Thanks.



28.12. The Password File

The file .pgpass in a user's home directory or the file referenced by
PGPASSFILE can contain passwords to be used if the connection requires a
password (and no password has been specified otherwise). On Microsoft
Windows the file is named %APPDATA%\postgresql\pgpass.conf (where
%APPDATA% refers to the Application Data subdirectory in the user's
profile).

This file should contain lines of the following format:

hostnameort:database:usernameassword

Each of the first four fields may be a literal value, or *, which
matches anything. The password field from the first line that matches
the current connection parameters will be used. (Therefore, put
more-specific entries first when you are using wildcards.) If an entry
needs to contain : or \, escape this character with \. A hostname of
localhost matches both host (TCP) and local (Unix domain socket)
connections coming from the local machine.

The permissions on .pgpass must disallow any access to world or group;
achieve this by the command chmod 0600 ~/.pgpass. If the permissions are
less strict than this, the file will be ignored. (The file permissions
are not currently checked on Microsoft Windows, however.)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.