windows - 在 Windows 上设置 postgres 用户密码

标签 windows postgresql passwords

我想为 Windows 本地数据库上的 postgres 用户设置密码。

目前我可以使用以下方式登录postgres “psql -U postgres” 无需密码

我的pg_hba文件如下

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

最佳答案

首先像往常一样使用psql -U postgres登录并为用户postgres设置密码:

ALTER USER postgres PASSWORD 'your-new-password';

编辑文件 pg_hba.conf 并添加以下行:

local   all             postgres                                   md5

最后重新启动postgres服务器。

关于windows - 在 Windows 上设置 postgres 用户密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32246765/

相关文章:

Python 程序共存于 Windows

postgresql - 如何解决 postgresql 错误 "connection attempt failed"?

database - 如何将用户密码安全地存储在 Cloudant 数据库中?

node.js - 使用 Node.JS createClient() 方法时,与 Redis 客户端一起使用的相同 Redis 密码失败了吗?

java - 如何使用命令提示符在两个 jar 文件之间创建管道?

c++ - 如何在 Windows 上解析由 std::put_time ("%x") 创建的字符串?

sql - TypeORM 限制不起作用,无论设置多少限制,查询都会返回数组中的一个元素?

java - 使用 Java 在 Lotus Notes 客户端输入不正确的用户 ID 密码时控制台挂起

C# 事件处理程序

node.js - 如何将 SSL 证书 (ca-cert) 添加到 node.js 环境变量以连接到 Digital Ocean Postgres 托管数据库?