安装 PostgreSQL 16
apt install postgresql-16
passwd postgres
,修改 postgres 用户密码su postgres
psql -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-256
systemctl 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-3
su postgres
psql -U postgres
create database "test_data";
- \c test_data 连接
create extension postgis;
select PostGIS_version();
验证安装- \c postgres
select * from pg_database;
drop database "test_data";