PostgreSQL 9.2.4(Windows 7)-服务无法启动,“无法加载pg_hba.conf”。 [英] PostgreSQL 9.2.4 (Windows 7) - Service won't start, "could not load pg_hba.conf"

查看:430
本文介绍了PostgreSQL 9.2.4(Windows 7)-服务无法启动,“无法加载pg_hba.conf”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to get Postgres 9.2.4 to run as a service on Windows 7. After installing postgres, the service was running fine. However, after setting postgres up as a server for another program, the service stopped running. When I try to start the service now, I get a message saying :


postgresql-x64-9.2-PostgreSQL Server 9.2服务在本地
计算机启动然后停止。如果
未被其他服务或程序使用,则某些服务会自动停止。

"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."

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

When I try running the program that should use the database server, I get this error :


尝试登录或创建
生产数据库时。详细信息:无法连接到服务器;
无法连接到远程套接字。应用程序现在必须关闭

"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"

我在打开同一程序时也遇到了此错误:

I have also encountered this error once while opening the same program :


尝试登录或创建
生产数据库时遇到问题详细信息:致命:无法加载pg_hba.conf
应用程序不能w 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条目的内容:

I have tried running the service logged on as a local system account as well as my own account (In the postgres service properties) to no avail. I also tried restarting my computer. After a lot of troubleshooting online, I learned that a good thing to check is the pg_log file. Here are the contents of the latest pg_log entry :

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文件似乎有问题,如下所示:

It seems to be having issues with the pg_hba.conf file, which looks like this :

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

根据在线上的许多建议,我尝试将顶行编辑为多种不同的选择(托管所有信任/托管全部127.0.0.1/32信任/主机全部192.168.0.100/24信任等)。这对我来说很有意义,因为日志文件说postgres不支持本地连接,并且也指向该行。但是,我的任何更改都没有任何效果。我尝试在每次更改后重新启动计算机,但是没有任何区别。

As per many suggestions online, I tried editing the top line to a number of different alternatives (host all all trust / host all 127.0.0.1/32 trust / host all 192.168.0.100/24 trust , etc.). This made sense to me, as the log file was saying that local connections are unsupported by postgres and was also pointing to that line. However, none of my changes had any effect. I tried restarting my computer after every change but nothing made any difference.

当我搜索pg_hba.conf文件通常看起来是什么样的示例时,这些示例看起来略有不同从我的档案中。我注意到在PostgreSQL程序文件中,除了pg_hba.conf之外,还有一个 20130529-150444-old-pg_hba.conf文件,看起来更像是我在网上找到的示例。该文件在最后几行之前有几行注释:

When I searched for examples of what a pg_hba.conf file normally looks like, the examples looked slightly different from my file. I noticed that in the PostgreSQL program file, in addition to pg_hba.conf, there was also a "20130529-150444-old-pg_hba.conf" file which looked a lot more like the examples I was finding online. This file has several lines of comments before these last few lines :

# 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中记录更多错误文件,以查看先前指出的错误是否已消失或更改为其他错误,但没有更多文件被记录。

I was hoping that this was the original pg_hba.conf file and that if I replaced the new file with the contents of the old one, postgres would start working again. No such luck. I have been hoping for more error files to be logged in pg_log to see if the previously stated error had disappeared or changed to something else, but no more files have been logged.

我已经在线进行了数天的故障排除,但没有发现任何有效的方法。抱歉,提出了这么长的问题,但我想透彻一点,并包括所有相关信息。如果有人可以阐明此问题或提出建议,我将不胜感激。

I have been troubleshooting online for a few days now and nothing I've found has worked. Sorry for having such a long question, but I wanted to be thorough and include all relevant information. I would appreciate it if anyone could shed some light on this problem or offer suggestions.

推荐答案

Windows不支持本地条目机器。参见 E.20.3.1.3。身份验证

The local entry is not supported on Windows machines. See E.20.3.1.3. Authentication.


在不支持
Unix套接字连接的平台上拒绝pg_hba.conf中的本地行(马格努斯·哈甘德)

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。 pg_hba.conf文件

For more info, consult 19.1. The pg_hba.conf File.

这篇关于PostgreSQL 9.2.4(Windows 7)-服务无法启动,“无法加载pg_hba.conf”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆