PostgreSQL 无法在 Windows XP 上启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13116511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 00:29:07  来源:igfitidea点击:

PostgreSQL fails to start on Windows XP

postgresqlservicewindows-xp

提问by Abraham P

I am attempting to set up a Windows XP Test Agent running Ruby on Rails against a PostgreSQL Database. I've installed PostgreSQL 9.2 for Windows, with default settings. However, when I attempt to start the service from the Service Control Panel, the following error message appears(irrelevantly of which User I attempt to set it to):

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

   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.

If I attempt to launch it from the command line (whether cmd.exe or git bash doesn't matter with):

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

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

It will claim:

它将声称:

   server starting

However it will fail to start (rake db:migrate will report the server as not running, the postgresql process is missing from Task Manager, the Service is listed as down in the Service List, and

但是它将无法启动(rake db:migrate 将报告服务器未运行,任务管理器中缺少 postgresql 进程,该服务在服务列表中被列为关闭,并且

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

Will report

会报

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

While attempting to start it as a server through pg_ctl:

尝试通过 pg_ctl 将其作为服务器启动时:

  E:\PostgreSQL.2\bin\pg_ctl.exe runservice  -D E:\PostgreSQL.2\data

Fails with:

失败:

  pg_ctl: could not start service PostgreSQL: error code 1063

EDIT:

编辑:

the contents of pg_hba:

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

Checking in pg_log as per comments below:

根据以下评论检查 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

Line 78 is

第 78 行是

 local   all             all                all                  trust

The same error still occurs when running as a service (whether through pg_ctl runservice or from the services control panel). However pg_ctl start now starts postgres without incident.

作为服务运行时(无论是通过 pg_ctl runservice 还是从服务控制面板),同样的错误仍然发生。然而 pg_ctl start 现在启动 postgres 没有任何意外。

I'll go with "good enough"

我会说“足够好”

PS: The Event Log entries merely say "Timed out waiting for server startup"

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

回答by Craig Ringer

UPDATEAfter edits to question:

更新问题编辑后:

Delete the lines from pg_hba.confthat begin with local. They relate to UNIX socket connections, which PostgreSQL does not support. Then, unless something else is also wrong, you should be able to start PostgreSQL. Most likely you copied and pasted a pg_hba.conffrom a site that talks about PostgreSQL on Mac OS X or Linux, where localconnections are supported.

删除以pg_hba.conf开头的行local。它们与 PostgreSQL 不支持的 UNIX 套接字连接有关。然后,除非还有其他问题,否则您应该能够启动 PostgreSQL。很可能您pg_hba.conf从一个讨论 Mac OS X 或 Linux 上的 PostgreSQL 的站点复制并粘贴了,其中local支持连接。

If Pg still fails to start after fixing pg_hba.conf, check the logs again and see what else it's complaining about.

如果修复后 Pg 仍然无法启动pg_hba.conf,请再次检查日志,看看它还有什么抱怨。

By the way, in general I don't recommend trying to run PostgreSQL both as a service and via pg_ctlfrom the same data directory. You're likely to land up with file systems permissions problems that are difficult and annoying to resolve, especially on Windows.

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



In addition to @mvp's suggestions, it's possible that you are trying to start PostgreSQL under a user that is a member of the Administrators group. This is not permitted and will fail. I disagree with that policy, but that's how it is at the moment.

除了@mvp 的建议之外,您还可能尝试在属于管理员组成员的用户下启动 PostgreSQL。这是不允许的,并且会失败。我不同意该政策,但目前情况就是如此。

By default 9.2 is set up to run under the NetworkService, so that should not be a problem. If you configured it to run under a different user account this could be your problem, and it could be the problem when running it manually too.

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

It's more likely that when starting it manually you just don't have file system permissions to the data directory.

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

BTW, if E:\is FAT32, there's your problem. FAT32 is not supported. You must use NTFS.

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

Rather than stab in the dark, you should really be looking at the server logs in E:\PostgreSQL\9.2\data\pg_logand the event viewer to see what's causing it to fail to start.

而不是暗中刺伤,您应该真正查看服务器登录E:\PostgreSQL\9.2\data\pg_log和事件查看器,看看是什么导致它无法启动。

回答by mvp

You must have permission problem. PostgreSQL on windows wants to run as a postgres user. Installer will automatically create one and assign it new password.

你肯定有权限问题。Windows 上的 PostgreSQL 想要作为 postgres 用户运行。安装程序将自动创建一个并为其分配新密码。

There are few solutions to this. If you have just installed this database, then easiest solution is to uninstall Postgres, delete local postgres user (via control userpasswords2) and finally install Postgres again (be sure that you have admin rights on this box). Good luck!

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