从Windows命令行启动postgres 9.4服务器

我正在尝试从Windows命令行启动postgres erver,但是它保持与相同的错误失败:

2015-04-14 10:25:19 GST LOG: could not bind IPv6 socket: No error 2015-04-14 10:25:19 GST HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 2015-04-14 10:25:19 GST LOG: could not bind IPv4 socket: No error 2015-04-14 10:25:19 GST HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 2015-04-14 10:25:19 GST WARNING: could not create listen socket for "*" 2015-04-14 10:25:19 GST FATAL: could not create any TCP/IP sockets 

我能够访问服务器,如果我尝试从pgAdmin连接到它。 我没有任何其他服务在5432上运行,因为我已经检查任务pipe理器在该端口上运行的应用程序。

我正在使用的命令是

 pg_ctl start -D "C:\Program Files (x86)\PostgreSQL\9.4\data" 

但我也试过了

 postgres -D "C:\Program Files (x86)\PostgreSQL\9.4\data" 

我的IPv6设置设置为dynamicIP,而我的V4设置设置为我的宽带调制解调器IP。 我也禁用了Windows防火墙和我的防病毒AVG。 我究竟做错了什么?

最可能的解释是该端口上已经存在一个服务,但是在任务pipe理器中没有看到它,因为默认情况下它只显示用户拥有的任务。

在pipe理员命令提示符下运行时,请检查netstat命令的输出。

还可以在services.msc查找可能正在运行的postgresql-9.4-x86服务。

请注意,除了这个问题,PostgreSQL通常应该作为Windows服务来运行。 如果不存在,使用pg_ctl register创build一个服务。

如果你想手动运行PostgreSQL,我build议initdb自己的数据目录,而不是重新使用安装程序创build的目录。 如果您稍后切换回作为服务运行,则可能会遇到文件权限问题。