postgresql 修改配置,允许外部访问

时间:2018-09-23 11:51:27   收藏:0   阅读:1118

1、通过命令找到数据库配置文件的位置

api=# show config_file;
               config_file               
-----------------------------------------
 /etc/postgresql/10/main/postgresql.conf
(1 row)

2、我们需要修改两个配置配置文件的内容:

技术分享图片

? ~ sudo vim /etc/postgresql/10/main/pg_hba.conf

技术分享图片

把红色部分修改为:0.0.0.0/0

? ~ sudo vim /etc/postgresql/10/main/postgresql.conf

技术分享图片

搜索address,找到红色划线的部分

listen_addresses = ‘localhost‘取消注释,更改为:listen_addresses = ‘*‘ 

3、配置文件更改完之后,重启postgresql,配置即可生效,数据库就可以通过外部进行访问了。

?  ~ sudo systemctl restart postgresql 

 

 

  

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!