PostgreSQL无法在Windows XP上启动

时间:2012-10-29 05:50:46

标签: postgresql service windows-xp

我正在尝试针对PostgreSQL数据库设置运行Ruby on Rails的Windows XP测试代理。我已经安装了PostgreSQL 9.2 for Windows,默认设置。但是,当我尝试从服务控制面板启动服务时,会出现以下错误消息(与我尝试将其设置为的用户无关):

   The postgres-9.2 -PostgreSQL Server 9.2 service on Local Computer started and then stopped. Some services 
   stop automatically if they have work to do, for example, the Performance Logs and Alerts service.

如果我尝试从命令行启动它(cmd.exe或git bash无关紧要):

   E:\PostgreSQL\9.2\bin\pg_ctl.exe start  -D E:\PostgreSQL\9.2\data

它会声称:

   server starting

然而,它将无法启动(rake db:migrate将报告服务器未运行,任务管理器中缺少postgresql进程,服务在服务列表中列为down,并且

  E:\PostgreSQL\9.2\bin\pg_ctl.exe stop  -D E:\PostgreSQL\9.2\data

将报告

  pg_ctl: PID file "E:/PostgreSQL/9.2/data/postmaster.pid" does not exist Is server running?

尝试通过pg_ctl:

将其作为服务器启动时
  E:\PostgreSQL\9.2\bin\pg_ctl.exe runservice  -D E:\PostgreSQL\9.2\data

失败:

  pg_ctl: could not start service PostgreSQL: error code 1063

编辑:

pg_hba的内容:

 # TYPE  DATABASE        USER            ADDRESS                 METHOD
 local   all             all                all                  trust
 # IPv4 local connections:
 host    all             all                all                  trust
 host    all             all             127.0.0.1/32            trust
 # IPv6 local connections:
 #host    all             all             ::1/128                trust
 # Allow replication connections from localhost, by a user with the
 # replication privilege.
 #host    replication     all                all                 trust
 #host    replication     postgres        127.0.0.1/32           trust
 #host    replication     postgres        ::1/128                trust

根据以下评论检入pg_log:

 2012-10-28 22:47:44 PDT LOG:  local connections are not supported by this build
 2012-10-28 22:47:44 PDT CONTEXT:  line 78 of configuration file "E:/PostgreSQL/9.2/data/pg_hba.conf"
 2012-10-28 22:47:44 PDT FATAL:  could not load pg_hba.conf

第78行

 local   all             all                all                  trust

作为服务运行时仍然会出现相同的错误(无论是通过pg_ctl runservice还是从服务控制面板)。但是pg_ctl start现在开始postgres而没有发生任何事故。

我会选择“足够好”

PS:事件日志条目只是说“等待服务器启动超时”

2 个答案:

答案 0 :(得分:5)

更新编辑后的问题:

删除以pg_hba.conf开头的local行。它们与UNIX套接字连接有关,而PostgreSQL不支持这种连接。然后,除非其他东西也是错误的,你应该能够启动PostgreSQL。您很可能从一个在Mac OS X或Linux上讨论PostgreSQL的网站复制并粘贴了pg_hba.conf,其中支持local个连接。

如果Pg在修复pg_hba.conf后仍无法启动,请再次检查日志并查看其抱怨的内容。

顺便说一下,一般来说,我不建议尝试将PostgreSQL作为服务运行,并通过同一数据目录中的pg_ctl运行。您可能会遇到难以解决的文件系统权限问题,尤其是在Windows上。


除了@ mvp的建议之外,您可能正在尝试在属于Administrators组成员的用户下启动PostgreSQL。这是不允许的,并且会失败。我不同意这个政策,但现在就是这样。

默认情况下,9.2设置为在NetworkService下运行,因此不应该是一个问题。如果您将其配置为在不同的用户帐户下运行,这可能是您的问题,并且在手动运行时也可能是问题。

更有可能的是,手动启动它时,您只是没有数据目录的文件系统权限。

顺便说一下,如果E:\是FAT32,那就是你的问题。不支持FAT32。您必须使用NTFS。

你应该真正关注E:\PostgreSQL\9.2\data\pg_log和事件查看器中的服务器日志,看看导致它无法启动的原因,而不是在黑暗中刺伤。

答案 1 :(得分:3)

您必须拥有权限问题。 Windows上的PostgreSQL希望以postgres用户身份运行。安装程序将自动创建一个并为其分配新密码。

这方面的解决方案很少。如果您刚刚安装了此数据库,那么最简单的解决方案是卸载Postgres,删除本地postgres用户(通过control userpasswords2),最后再次安装Postgres(确保您拥有此框的管理员权限)。祝你好运!

相关问题