我在 Windows 10 上使用 WAMP,我添加了 PostgreSQL 和 PhpPgAdmin,一切正常。今天我无法通过 PhpPgAdmin 或 php_pdo 网络应用程序登录 PostgreSQL。
我尝试在 2 个位置编辑 pg_hba.conf
c:\PostgreSQL\pg96\init\
和 c:\PostgreSQL\data\pg96\
并根据许多答案将“方法”更改为 trust
here ,所有 CLI 答案均无效。
我还重新启动了“WAMP”甚至整个计算机,但没有成功。
默认密码在 postgres
和 root
之前有效,但现在无效。
如何重置 postgre 密码?
更新
运行 psql -U postgres
返回;
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
pg_hba.conf 的内容
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local & remote connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 trust
最佳答案
所以经过更多的挖掘,并不是密码错误,而是出于某种原因,PostgreSQL 甚至没有运行。 Windows 就是这样一个 PITA!
最后,从 CMD 运行 pg_ctl -D "C:\PostgreSQL\data\pg96"start
就可以了。现在我们看看它明天是否开始......我想念我的 Unix 环境。
-----更新-----
虽然上面的代码有效,但它的方向是错误的。
转到 Control Panel->Administrative Tools->Services
并在列表中找到“PostgreSQL ...”。右键单击并打开“属性”。
我的启动类型:
设置为“自动”但它没有启动,我将其设置为“自动(延迟启动)” ' 现在它可以自动运行了!
关于postgresql - 如何重置postgres密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46223116/