如何将本地postgresql与本地ip地址连接

如何将本地postgresql与本地ip地址连接,sql,database,postgresql,Sql,Database,Postgresql,我的问题是,我在我的Mac电脑上安装了postgresql,然后我想将我的postgresql连接到我的本地IP地址 例如,我的本地IP地址是:10.xxx.xxx.xxx,我希望命令名为psql-U username-d dbname-h 10.xxx.xxx.xxx到命令名的实例psql-U username-d dbname-h 127.0.0.1 我已将我的IP地址添加到pg_hba.conf,并将postgresql.conf中的listen_address更改为listen_addr

我的问题是,我在我的Mac电脑上安装了postgresql,然后我想将我的postgresql连接到我的本地IP地址

例如,我的本地IP地址是:10.xxx.xxx.xxx,我希望命令名为
psql-U username-d dbname-h 10.xxx.xxx.xxx
到命令名的实例
psql-U username-d dbname-h 127.0.0.1

我已将我的IP地址添加到
pg_hba.conf
,并将
postgresql.conf
中的
listen_address
更改为
listen_address='*'
,但未工作


谢谢您的回答。

/etc/hosts
文件中添加您的本地IP,然后重试。如下图所示:

127.0.0.1   localhost
10.xxx.xxx.xxx  localhost

检查端口是否在127.0.0.1和10.xxx.xxx.xxx之间打开表示10.xxx.xxx.xxx等于127.0.0.1我只有一台计算机。您是否尝试过在没有-h选项的情况下正常连接,我尝试连接127.0.0.1,并成功。但是10.xxx.xxx.xxx失败了。