Ubuntu-24.04.2-安装-PostgreSQL-16-PostGIS-3
目录
Ubuntu 24.04.2 安装 PostgreSQL 16 、PostGIS 3
安装 PostgreSQL 16
apt install postgresql-16passwd postgres,修改 postgres 用户密码su postgrespsql -U postgres, 以 postgres 的身份登录数据库alter user postgres with password 'abc123';\q 退出
/etc/postgresql/16/main/postgresql.conf 可修改
#listen_addresses = '*',可修改端口 25432/etc/postgresql/16/main/pg_hba.conf 修改连接
# IPv4 local connections: host all all 127.0.0.1/32 trust host all all 0.0.0.0/0 scram-sha-256systemctl restart postgresql重启su root,lsof -i:25432可以查看是否运行,systemctl disable postgresql可禁止自启动apt install ufw,ufw enable,ufw allow 25432/tcp
安装 PostGis 3
apt install postgresql-16-postgis-3su postgrespsql -U postgrescreate database "test_data";- \c test_data 连接
create extension postgis;select PostGIS_version();验证安装- \c postgres
select * from pg_database;drop database "test_data";