service - PostgreSQL 9.2.4 (Windows 7) - 服务无法启动, "could not load pg_hba.conf"

标签 service installation database-connection windows-7-x64 postgresql-9.2

我试图让 Postgres 9.2.4 在 Windows 7 上作为服务运行。安装 postgres 后,该服务运行良好。但是,在将 postgres 设置为另一个程序的服务器后,该服务停止运行。当我现在尝试启动服务时,我收到一条消息:

"The postgresql-x64-9.2 - PostgreSQL Server 9.2 service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs."



当我尝试运行应该使用数据库服务器的程序时,出现此错误:

"A problem was encountered while attempting to log into or create the production database. Details: Could not connect to the server; Could not connect to remote socket. The application must now close"



我在打开同一个程序时也遇到过这个错误:

"A problem was encountered while attempting to log into or create the production database. Details: FATAL: could not load pg_hba.conf The application must now close."



我曾尝试运行以本地系统帐户以及我自己的帐户(在 postgres 服务属性中)登录的服务,但无济于事。我也尝试重新启动我的电脑。经过网上大量的故障排除后,我了解到检查 pg_log 文件是一件好事。以下是最新的 pg_log 条目的内容:
2013-05-29 14:59:45 MDT LOG:  database system was interrupted; last known up at 2013-05-29 14:58:01 MDT
2013-05-29 14:59:45 MDT LOG:  database system was not properly shut down; automatic recovery in progress
2013-05-29 14:59:45 MDT LOG:  record with zero length at 0/175BB98
2013-05-29 14:59:45 MDT LOG:  redo is not required
2013-05-29 14:59:45 MDT LOG:  database system is ready to accept connections
2013-05-29 14:59:45 MDT LOG:  autovacuum launcher started
2013-05-29 15:07:00 MDT LOG:  local connections are not supported by this build
2013-05-29 15:07:00 MDT CONTEXT:  line 1 of configuration file "C:/PostgreSQL/data/pg_hba.conf"
2013-05-29 15:07:00 MDT FATAL:  could not load pg_hba.conf
2013-05-29 15:07:00 MDT LOG:  local connections are not supported by this build
2013-05-29 15:07:00 MDT CONTEXT:  line 1 of configuration file "C:/PostgreSQL/data/pg_hba.conf"
2013-05-29 15:07:00 MDT FATAL:  could not load pg_hba.conf
2013-05-29 15:09:03 MDT LOG:  received fast shutdown request
2013-05-29 15:09:03 MDT LOG:  aborting any active transactions
2013-05-29 15:09:03 MDT LOG:  autovacuum launcher shutting down
2013-05-29 15:09:03 MDT LOG:  shutting down
2013-05-29 15:09:03 MDT LOG:  database system is shut down

pg_hba.conf 文件似乎有问题,如下所示:
local all all trust
host all all 127.0.0.1 255.255.255.255 trust
host all all 0.0.0.0 0.0.0.0 trust

根据网上的许多建议,我尝试将顶行编辑为许多不同的替代方案(host all all tr​​ust/host all 127.0.0.1/32 trust/host all 192.168.0.100/24 trust 等)。这对我来说很有意义,因为日志文件说 postgres 不支持本地连接并且也指向该行。但是,我的任何更改都没有任何效果。每次更改后我都尝试重新启动计算机,但没有任何区别。

当我搜索 pg_hba.conf 文件通常是什么样子的示例时,这些示例看起来与我的文件略有不同。我注意到在 PostgreSQL 程序文件中,除了 pg_hba.conf 之外,还有一个“20130529-150444-old-pg_hba.conf”文件,它看起来更像我在网上找到的例子。该文件在最后几行之前有几行注释:
# 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

我希望这是原始的 pg_hba.conf 文件,如果我用旧文件的内容替换新文件,postgres 将再次开始工作。没有这样的运气。我一直希望在 pg_log 中记录更多错误文件,以查看先前陈述的错误是否已消失或更改为其他错误,但没有记录更多文件。

我已经在网上进行故障排除几天了,但我发现没有任何效果。很抱歉问了这么长的问题,但我想彻底了解并包含所有相关信息。如果有人能对这个问题有所了解或提供建议,我将不胜感激。

最佳答案

Windows 计算机不支持本地条目。见 E.20.3.1.3. Authentication .

Reject local lines in pg_hba.conf on platforms that don't support Unix-socket connections (Magnus Hagander)

Formerly, such lines were silently ignored, which could be surprising. This makes the behavior more like other unsupported cases.



更改您的配置:
local  all    all     trust

到:
host   all    all   127.0.0.1/32  trust
host   all    all   ::1/128       trust

更多信息请咨询19.1. The pg_hba.conf File .

关于service - PostgreSQL 9.2.4 (Windows 7) - 服务无法启动, "could not load pg_hba.conf",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846363/

相关文章:

mysql - 连接 MySQL 服务器失败

C# Windows 服务并不总是在关机时停止

eclipse - 如何在 Aptana Studio 3+ 上安装 Eclipse 插件

php - zend - 从 Controller 连接到数据库

android - Android Studio Gradle卡住了

python - OSX 安装 Python 分发

java - 根据从数据库检索的数据设置变量

android - 当 onCreate() 调用 startService() 时我能期待什么

android - 从 Activity 中收听绑定(bind)位置服务

c# - 数据包格式不正确,使用 WSDL 文件从 C# 调用 SAP 服务