PostGIS on Ubuntu

安装

https://postgis.net/install/
Ubuntu直接看这篇:https://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS24UbuntuPGSQL10Apt

开放TCP

查找pg_hba.conf文件

root@ubuntu:~# locate postgresql.conf
/etc/postgresql/14/main/postgresql.conf
/root/postgres-master/src/backend/utils/misc/postgresql.conf.sample
/usr/local/pgsql/data/postgresql.conf
/usr/share/postgresql/14/postgresql.conf.sample

修改:

listen_addresses = '0.0.0.0'            # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 5432                             # (change requires restart)

开放登录

查找pg_hba.conf文件

root@ubuntu:~# locate pg_hba.conf
/etc/postgresql/14/main/pg_hba.conf
/root/postgres-master/src/backend/libpq/pg_hba.conf.sample
/usr/local/pgsql/data/pg_hba.conf
/usr/share/postgresql/14/pg_hba.conf.sample

添加规则:

# 明文认证,有的psql客户端不支持高级认证方式
host    all             all              0.0.0.0/0              password
# 与明文对立的有md5等方式
host    all             all              0.0.0.0/0              md5
# 直接信任某IP,无需验证密码
host    all             all              x.x.x.x/0              trust

修改密码

进入psql命令行:

alter user postgres with password 'passwd'; 

重启

systemctl restart postgresql.service

see

http://www.project-open.com/en/howto-postgresql-port-secure-remote-access

posted @ 2022-04-28 17:11  develon  阅读(24)  评论(0编辑  收藏  举报