簡體   English   中英

無法連接到數據庫Postgres pg_hba(OSX)

[英]Could not connect to database postgres pg_hba (OSX)

因此,我試圖在我的Mac 10.9 Mavericks計算機上將PostgreSQL與metasploit一起使用。 我正在嘗試按照此頁面上概述的說明進行操作。 http://www.darkoperator.com/installing-metasploit-framewor/ ,我得到了以下命令:

createuser msf -P -h localhost

結果如下:

$ createuser msf -P -h localhost
Enter password for new role: 
Enter it again: 
createuser: could not connect to database postgres: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "myname", database "postgres", SSL off

我將顯示“我的名字”的部分更改為該部分,因為我不想在這里張貼我的名字。 我已經在互聯網上搜尋了幾天的解決方案,並且我確定我需要編輯pg_hba.conf。 這是我的pg_hba.conf文件的內容:

 80 # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
 81 
 82 # "local" is for Unix domain socket connections only
 83 #local   all         all                               trust
 84 host     all         all        0.0.0.0/0             md5
 85 local   all         all                               md5
 86 # IPv4 local connections:
 87 host    all         all         127.0.0.1/32          md5
 88 # IPv6 local connections:
 89 host    all         all         ::1/128               md5
 90 
 91 # TYPE  DATABASE        USER            ADDRESS                 METHOD
 92 #local   postgres        postgres                                trust
 93 #local   msf_db          msf_user                                trust
 94 # Allow replication connections from localhost, by a user with the
 95 # replication privilege.
 96 #local   replication     postgres                                trust
 97 #host    replication     postgres        127.0.0.1/32            trust
 98 #host    replication     postgres        ::1/128                 trust

您能告訴我我需要從本節中添加/刪除(注釋掉)以啟動和運行postgresql嗎?

如果您需要更多信息以幫助我學習如何解決此問題,請告訴我。 謝謝!!

編輯1:

有人告訴我,我需要做的就是重新啟動數據庫,這就是我得到的:

sh-3.2# pg_ctl stop -D /opt/local/var/db/postgresql93/defaultdb
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

我以su身份登錄以完成此操作...

編輯2:

然后,我嘗試使用默認用戶來完成此操作,這就是我所得到的(我確定自己輸入了正確的密碼)

sxxx:~ sxxx$ createuser msf -P -h localhost
Enter password for new role: 
Enter it again: 
Password: 
createuser: could not connect to database postgres: FATAL:  password authentication failed for user "sxxx"

編輯3:

感謝其他人的幫助,我發現我需要登錄到我的postgres用戶才能創建它。 我仍然無法完成以下操作:

Sxxx-MacBook-Pro:~ sxxx$ sudo su - postgres
Sxxx-MacBook-Pro:~ postgres$ createuser msf -P -h localhost
Enter password for new role: 
Enter it again: 
createuser: could not connect to database postgres: FATAL:  role "postgres" does not exist

在我看來,這很奇怪。

編輯4:

我奇跡般地關閉了終端窗口,然后打開了一個新的窗口,在整個工作過程中我一直都在做同樣的事情:

Sxxx-MacBook-Pro:~ sxxx$ createuser msf -P -h localhost
Enter password for new role: 
Enter it again: 
Sxxx-MacBook-Pro:~ sxxx$ createdb -O msf msf -h localhost
Sxxx-MacBook-Pro:~ sxxx$ 

檢查運行PostgreSQL的用戶。 通常這將是pgsqlpostgres 以該用戶身份運行createuser命令。

$ sudo su
# su postgres -c 'createuser msf -P -h localhost'

您可能不需要觸摸pg_hba.conf文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM