美文网首页
postgresql 外网访问设置

postgresql 外网访问设置

作者: 东方翔 | 来源:发表于2017-08-06 23:44 被阅读0次

自己的一台破电脑被用来做服务器了,上面装了postgresql,需要能在局域网内访问,就查阅了写资料,总结如下。如果要外网访问的话,相似的改动相应ip就可以了。

1. select name, setting from pg_settings where category = 'File Locations'   找到配置文件地址。

我使用的是9.5版本, 返回结果如下

查询返回结果

2. 上述的查询结果中,有hba_file的地址,打开 /etc/postgresql/9.5/main/pg_hba.conf 并做相应修改 

hba_file修改前 hba_file修改后

3. 在第一个查询的返回结果中,同样有 config_file的地址,打开 /etc/postgresql/9.5/main/postgresql.conf 并做相应修改。在其中添加 `   listen_addresses = '*'   `

4.  重启数据库  sudo service postgresql restart

相关文章

网友评论

      本文标题:postgresql 外网访问设置

      本文链接:https://www.haomeiwen.com/subject/xgonlxtx.html