以下是Debian下PostgreSQL的配置步骤:
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo -u postgres psql
CREATE USER myuser WITH PASSWORD 'mypassword';
CREATE DATABASE mydb OWNER myuser;
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
\q
postgresql.conf
:sudo nano /etc/postgresql/<version>/main/postgresql.conf
listen_addresses = '*'
pg_hba.conf
:sudo nano /etc/postgresql/<version>/main/pg_hba.conf
host all all 0.0.0.0/0 scram-sha-256
sudo systemctl restart postgresql
sudo ufw allow 5432/tcp
sudo -u postgres psql
→ ALTER USER postgres WITH PASSWORD 'new_password';
postgresql.conf
中ssl on
相关参数说明:
<version>
需替换为实际安装的PostgreSQL版本号(如15
)。listen_addresses
为特定IP,并使用强密码策略。