2013-11-25 43 views
12

我正在通過brew進行安裝。PostgreSQL無法創建任何TCP/IP套接字小牛隊

該錯誤消息(一個或多個):

當我打電話

postgres 

我收到錯誤

LOG: could not bind IPv6 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
LOG: could not bind IPv4 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
LOG: could not bind IPv6 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
WARNING: could not create listen socket for "localhost" 
FATAL: could not create any TCP/IP sockets 

運行

postgres -D /usr/local/var/postgres 

創建相同的錯誤

createdb 

提示我要我的密碼兩次,然後說,

createdb: could not connect to database template1: FATAL: password authentication failed for user "thomasmurphy" 

我已經試過 *卸載和重新安裝PG寶石,卸載並重新安裝的Postgres *更新的命令行工具 *滿足釀酒醫生的所有需求 *編輯pg_hba.conf的權限 *編輯.bash_profile以確保它包含上述目錄

我的Postgres在我的工作電腦上運行得很完美,也是在小牛隊,所以這讓我覺得有點像邊緣情況。我可以嘗試解決這個問題還有哪些其他的方法?

+0

'另一位郵差管理員已經在端口5432上運行了嗎?' - 是嗎? –

+0

@RichardHouxton公平的問題。但是,不,5432上沒有連接。 –

+0

您是如何檢查的? –

回答

4

你得到的錯誤是因爲PostgreSQL正在運行。我怎麼知道?因爲它拒絕你的密碼。這很清楚。

現在您真正的問題可能是您需要在修改pg_hba.conf以重新啓動PostgreSQL以獲得信任訪問權限。然後,你可以:

ALTER USER foo WITH PASSWORD 'bar'; 

在啓動和重新啓動PostgreSQL的條款,請參閱這個問題:How to start PostgreSQL server on Mac OS X?

+0

我無法再重現這個問題了,因爲我在這臺機器上安裝了PostgreSQL。這個答案似乎與我遇到的問題一致,所以我會接受。 –

7

你得到的錯誤是東陽你的主機是broken.check你/etc/hosts文件。

127.0.0.1 localhost放在主機的第一行。

+0

它在我的情況下工作,但我不能解釋爲什麼?你還可以告訴在沒有在hosts文件中輸入這個條目有什麼問題嗎? –

+0

localhost與127.0.0.1不一樣。在某些應用程序中,本地主機不需要轉換爲IP地址。然而,它 – gpxlcj

+0

但它需要在這裏翻譯。PostgreSQL和主機配置文件都不建立本地主機和IP之間的關聯。 – gpxlcj

2

Linux:通過在命令行運行ifconfig,確保您的環回接口已啓動。如果它沒有啓動,你可以使用/sbin/ifconfig lo 127.0.0.1來啓動它。

+0

像魅力一樣工作。謝謝! – Sathish

0

它可能不是您的/etc/hosts壞了。即使正確的行在/etc/hosts中,也可能是其他內容打破了localhost,的DNS查找。

檢查nslookup localhost,看看你是否因此得到127.0.0.1。另請諮詢getent hosts localhost。作爲用戶Postgres運行的用戶,請檢查這些也是