所以我试图在我的 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$