Could you teach me, How can we specify password when using psql....

Started by 노현석over 15 years ago3 messagesgeneral
Jump to latest
#1노현석
noh019@naver.com

hi..

when using oracle sqlplus.. we can specify password.
$ sqlplus system/manager

Could you teach me, How can we specify password when using psql....
$ psql -p 5432 -h rac2 -d mydb -U hsnoh
Password for user hsnoh:

Thanks..

noh019님의 블로그
안녕하세요.

#2David Fetter
david@fetter.org
In reply to: 노현석 (#1)
Re: Could you teach me, How can we specify password when using psql....

On Fri, Aug 06, 2010 at 01:35:58PM +0900, 노현석 wrote:

hi..

when using oracle sqlplus.. we can specify password.
$ sqlplus system/manager

Could you teach me, How can we specify password when using psql....
$ psql -p 5432 -h rac2 -d mydb -U hsnoh
Password for user hsnoh:

Thanks..

Overall, it's better to use a .pgpass (pgpass.conf on Windows)

http://www.postgresql.org/docs/current/static/libpq-pgpass.html

It's also possible, but not recommended, to set an environment
variable.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fetter (#2)
Re: Could you teach me, How can we specify password when using psql....

David Fetter <david@fetter.org> writes:

On Fri, Aug 06, 2010 at 01:35:58PM +0900, 노현석 wrote:

when using oracle sqlplus.. we can specify password.
$ sqlplus system/manager

Could you teach me, How can we specify password when using psql....
$ psql -p 5432 -h rac2 -d mydb -U hsnoh
Password for user hsnoh:

Overall, it's better to use a .pgpass (pgpass.conf on Windows)

The reason why psql doesn't have that is that putting a password
directly on the command line is a security hole: any other process
on the machine can see psql's command line, on most platforms.

It's a security hole for Oracle, too --- you shouldn't be doing
things that way.

regards, tom lane