Thread: How to set password in psql -h -d -U command line?

How to set password in psql -h -d -U command line?

From
Shaozhong SHI
Date:
I tried various ways to set password in psql command line, but got no luck.

Can anyone help?

Regards,

David

Aw: How to set password in psql -h -d -U command line?

From
Karsten Hilbert
Date:
> I tried various ways to set password in psql command line, but got no luck.

Have you tried all the methods that you showed in your mail or did you try others as well ?

Best regards,
Karsten




Re: How to set password in psql -h -d -U command line?

From
Joao Miguel Ferreira
Date:
Hello,

I usually use this approach:

PGPASSWORD=secret psql -h 127.0.0.1 -p 5432 -U joao mydatabase

it has the down side that the password is shown in the command. need to be careful about that aspect


On Thu, Apr 28, 2022 at 10:33 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:
I tried various ways to set password in psql command line, but got no luck.

Can anyone help?

Regards,

David

Re: How to set password in psql -h -d -U command line?

From
Josha Inglis
Date:
Either set the PGPASSWORD environment variable or set up a .pgpass file

Josha

On Thu, 28 Apr 2022 at 19:33, Shaozhong SHI <shishaozhong@gmail.com> wrote:
I tried various ways to set password in psql command line, but got no luck.

Can anyone help?

Regards,

David
--
Kind Regards

Josha Inglis

Re: How to set password in psql -h -d -U command line?

From
alias
Date:

On Thu, Apr 28, 2022 at 3:13 PM Josha Inglis <joshainglis@gmail.com> wrote:
Either set the PGPASSWORD environment variable or set up a .pgpass file

Josha

On Thu, 28 Apr 2022 at 19:33, Shaozhong SHI <shishaozhong@gmail.com> wrote:
I tried various ways to set password in psql command line, but got no luck.

Can anyone help?

Regards,

David
--
Kind Regards

Josha Inglis