1、通过命令找到数据库配置文件的位置
api=# show <a href="https://www.gaodaima.com/tag/config" title="查看更多关于config的文章" target="_blank">config</a>_<a href="https://www.gaodaima.com/tag/file" title="查看更多关于file的文章" target="_blank">file</a>; config_file ----------------------------------------- /etc/<a href="https://www.gaodaima.com/tag/postgresql" title="查看更多关于postgresql的文章" target="_blank">postgresql</a>/10/main/postgresql.conf (1 row)
www#gaodaima.com来源gao@!dai!ma.com搞$$代^@码网搞代码
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
Python学习网,大量的免费PostgreSQL入门教程,欢迎在线学习!
来源:搞代码网:原文地址:https://www.gaodaima.com