[英]Which directory should I save a .pgpass file in when connecting to Postgresql from Python in Anaconda?
I've saved a .pgpass (properly configured) file in 我已将.pgpass(正确配置)文件保存在
`/Users/username/`
`/anaconda`
`/anaconda/bin/`
but the postgresql connection still requests my username and password. 但是postgresql连接仍然要求我的用户名和密码。 I'm using Anaconda and Spyder IDE.
我正在使用Anaconda和Spyder IDE。 Where should I save the .pgpass file?
.pgpass文件应保存在哪里?
Check permissions. 检查权限。 The
.pgpass
file has to have no group nor other permissions: .pgpass
文件不必具有组或其他权限:
chmod u-x,go-rwx ~/.pgpass
A command line psql client would actually warn you about it: 命令行psql客户端实际上会警告您:
WARNING: password file "/home/tometzky/.pgpass" has group or world access; permissions should be u=rw (0600) or less
Like the documentation says: 就像文档中说的那样:
The program must be using the C client library libpq
to connect to PostgreSQL (the JDBC driver, for example, doesn't use libpq
). 该程序必须使用C客户端库
libpq
连接到PostgreSQL(例如JDBC驱动程序不使用libpq
)。
The .pgpass
file must be in the home directory of the user that owns the process which uses libpq
to connect to PostgreSQL. .pgpass
文件必须位于拥有使用libpq
连接到PostgreSQL的进程的用户的主目录中。
You can override the default location by either putting the variable PGPASSFILE
in the process' environment or (from v10 on) with the connection parameter passfile
. 您可以通过将变量
PGPASSFILE
放在进程的环境中或(从v10开始)带有连接参数passfile
方式覆盖默认位置。
The .pgpass
file must have permissions 0600 or less. .pgpass
文件必须具有0600或更少的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.