以下是在Ubuntu上安装和配置PostgreSQL的步骤:
sudo apt update。sudo apt install postgresql postgresql-contrib。若要安装特定版本,如PostgreSQL 16,可使用sudo apt install postgresql-16 postgresql-contrib-16。/etc/postgresql/<版本>/main/postgresql.conf,将listen_addresses设为'*';编辑/etc/postgresql/<版本>/main/pg_hba.conf,添加host all all 0.0.0.0/0 scram-sha-256,然后重启服务:sudo systemctl restart postgresql。postgres用户,使用psql命令创建数据库和用户,如CREATE DATABASE mydb; CREATE USER myuser WITH PASSWORD 'mypassword'; GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;。以上步骤参考自。