以下是在Ubuntu中配置PostgreSQL的步骤:
sudo apt update和sudo apt upgrade,确保系统软件包最新。sudo apt install postgresql postgresql-contrib安装,postgresql-contrib包含额外功能模块,可根据需要选择安装。sudo systemctl status postgresql检查状态,若未启动则用sudo systemctl start postgresql启动,再用sudo systemctl enable postgresql设置开机自启。/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用户sudo -i -u postgres,使用createuser --interactive创建新用户,用createdb创建数据库,再通过GRANT语句赋予权限。