更新时间:2023-12-04 18:42:22
您可能希望阅读 向 PostgreSQL 进行身份验证的方法.
为了回答您的问题,有几种方法可以为基于密码的身份验证提供密码:
To answer your question, there are several ways provide a password for password-based authentication:
通过密码提示.示例:
psql -h uta.biocommons.org -U foo
Password for user foo:
在 pgpass 文件中.请参阅 libpq-pgpass.格式:
<host>:<port>:<database>:<user>:<password>
使用 PGPASSWORD
环境变量.请参阅 libpq-envars.示例:
export PGPASSWORD=yourpass
psql ...
# Or in one line for this invocation only:
PGPASSWORD=yourpass psql ...
在连接字符串中 可以在连接字符串/URI 中指定密码和其他选项.请参阅 app-psql.示例:
In the connection string The password and other options may be specified in the connection string/URI. See app-psql. Example:
psql postgresql://username:password@dbmaster:5433/mydb?sslmode=require