Re: hardcode password in connect string

From: Martín Marqués <martin(at)2ndquadrant(dot)com>
To: rod(at)iol(dot)ie, Ricardo Martin Gomez <rimartingomez(at)hotmail(dot)com>, James Keener <jim(at)jimkeener(dot)com>, David Gauthier <davegauthierpg(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: hardcode password in connect string
Date: 2018-04-15 20:10:04
Message-ID: 4ee7b3cf-bb0d-2131-d37e-ec8f547d0234@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

El 15/04/18 a las 12:16, Raymond O'Donnell escribió:
> On 15/04/18 12:35, Ricardo Martin Gomez wrote:
>> Hello David,
>> I think so, the parameter you need in psql command is -w mipassword.
>
> Sorry, this is not correct. -w causes psql *never* to prompt for a
> password, and -W forces a password prompt. Neither allows the password
> to be passed as an argument - I don't think that this is possible with
> psql.

It is possible, you just have to construct the whole string:

psql "host=thehost dbname=mydatabase user=memyselfi password=mypassword"

Still, the best option, and the most secure, is to use a .pgpass file.
The psql invocation with it's password will very likely end in
.bash_history and alike.

Regards,

--
Martín Marqués http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Azimuddin Mohammed 2018-04-16 00:22:48 Password encryption
Previous Message Guillaume Lelarge 2018-04-15 17:09:36 Re: hardcode password in connect string