一、添加APT仓库、安装
# Import the repository signing key:
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
# Create the repository configuration file:
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
# Update the package lists:
sudo apt update
sudo apt update
sudo apt install postgresql-18
二、修改postgres密码
1. root用户不能访问psql,使用postgresql账户。
sudo -i -u postgres
2. 进入psql
psql
3. 修改密码
\password
输入两遍密码。
三、配置pg_hba.conf
PostgreSQL有自己的安全组。
根据自己的需求放行有关安全组
以下是放行所有端口
host all all 0.0.0.0/0 scram-sha-256
四、配置postgresql.conf
监听网卡:
listen_addresses = '*'
systemctl restart postgresql


叨叨几句... NOTHING