2016-09-28 103 views
2

我已经安装的PostgreSQL服务器配置文件,但是当我在windows CMD运行命令postgresPostgres的不知道去哪里找

它提供了以下错误:

即使运行命令

postgres does not know where to find the server configuration file. 
You must specify the --config-file or -D invocation option or set the PGDATA environment variable. 

  • initdb postgres作为保持similar Issue
  • postgres -D C:\Program Files\PostgreSQL\data\ 给了我下面的输出:
2016-09-28 15:04:57 PDT LOG: could not bind IPv6 socket: Only one usage of each socket address (protocol/network address/port) is normally permitted. 
2016-09-28 15:04:57 PDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
2016-09-28 15:04:57 PDT LOG: could not bind IPv4 socket: Only one usage of each socket address (protocol/network address/port) is normally permitted.  
2016-09-28 15:04:57 PDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
2016-09-28 15:04:57 PDT WARNING: could not create listen socket for "*" 
2016-09-28 15:04:57 PDT FATAL: could not create any TCP/IP sockets 
2016-09-28 15:04:57 PDT LOG: database system is shut down 
+0

你究竟在做什么?你应该使用'pg_ctl'来启动Postgres服务器。做**不**使用'postgres'。 –

+0

我想将数据库连接到我的django应用程序,所以我需要一些数据库以及db中的用户 –

+2

如果您使用图形安装程序安装了Postgres,它将创建一个将自动启动的Windows服务。你有Postgres的Windows服务吗?为什么你认为你需要手动运行'postgres.exe'?如果使用'psql'连接到Postgres,会发生什么? –

回答

2

由于错误说,要启动一个PostgreSQL集群必须设置路径数据的文件夹。大概是这样的:

postgres -D "C:\Program Files\PostgreSQL\data\" 

但使用pg_ctl代替postgres建议:

pg_ctl -D "C:\Program Files\PostgreSQL\data\" start 

不要忘记检查的Postgres文档中关于how to start a serverhow to use pg_ctl

通常,postgres安装程序会创建一个服务/守护程序,因此不需要手动启动服务器。所以如果你得到一个错误,如

Is another postmaster already running on port 5432? 

这可能意味着服务器已经在运行。尝试使用它连接到psql

+0

它提供了:postgres:无效参数:“Files \ PostgreSQL \ 9.6 \ data” 尝试“postgres --help”以获取更多信息。 –

+1

@AkhileshKumar使用双引号:'-D“C:\ Program Files \ PostgreSQL \ data \”'但您应该使用'pg_ctl'来启动Postgres,**不**'postgres.exe' –

+0

虽然服务器已启动但仍然当我运行命令“postgres”它给出了同样的错误 –