postgresql: .pgpass not working

前端 未结 5 824
再見小時候
再見小時候 2021-02-03 19:16

I have created a .pgpass file in my home directory which looks like this

localhost:5432:somedb:someuser:somepass

I am using a shell scr

5条回答
  •  耶瑟儿~
    2021-02-03 20:16

    1. Create .pgpass file with content

    host:5432:somedb:someuser:somepass

    1. set the permissions

    sudo chmod 600 .pgpass

    1. Set the file owner as the same user using which you logged in :

    sudo chown login_username:login_username .pgpass

    1. Set PGPASSFILE environment variable :

    export PGPASSFILE='/home/user/.pgpass'

    Now check by connecting to database :

    psql -h host -U someuser somedb

    It did not prompt for a password, and logged-in to postgresql.

提交回复
热议问题