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

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 

  

猜你喜欢

转载自www.cnblogs.com/liangping/p/9691953.html