2016-09-28 65 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」它給出了同樣的錯誤 –