安裝 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";