如何强制 psql 在 Windows 10 系统上检测 .pgpass 文件? [英] How to force psql to detect .pgpass file on Windows 10 system?
问题描述
我在 Windows 10 系统上工作,python 3.9.4 in,anaconda env.我有一个 .pgpass
文件:localhost:port:db_name:user_name:password
I am working on Windows 10 system, python 3.9.4 in, anaconda env.
I have a .pgpass
file: localhost:port:db_name:user_name:password
当我跑步时:
psql -U user_name -d db_name -pXXXX
或
psql -U user_name -d db_name -pXXXX -f /path/to/sql/file.sql
它提示我输入密码.当我输入密码时,我可以连接,但我希望 psql 取而代之的是 pgpass 文件.
it prompts me for a password. When I enter the password I can connect, but I would like psql to pick up the pgpass file instead.
我的理论是:pgpass的格式.在 Windows 系统上是否需要特定的 EOL 字符?
My theory is: The format of the pgpass. Does it require specific EOL characters on Windows system?
localhost:port:db_name_1:user_name_1:password_1 <CR or LF>
localhost:port:db_name_2:user_name_2:password_2 <CR or LF>
推荐答案
我能够让它发挥作用.我必须创建postgresql"文件夹.它不在那里.之后,我添加了pgpass.conf"文件,我可以在没有密码提示的情况下从 conda 环境登录.
I was able to make it work. I had to create the 'postgresql' folder. It was not there. Afterwards, I added the 'pgpass.conf' file and I was able to login without password prompt from my conda environment.
/Users/user_name/AppData/Roaming/postgresql/pgpass.conf
感谢大家的帮助.
这篇关于如何强制 psql 在 Windows 10 系统上检测 .pgpass 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!