在Ubuntu上安装PostgreSQL,可参考以下步骤:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list',创建仓库配置文件。wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -,导入仓库签名密钥。sudo apt update,确保系统能识别新添加的仓库。sudo apt install -y postgresql postgresql-contrib,安装最新版本的PostgreSQL及其扩展包。若需安装特定版本,可将postgresql替换为对应版本号,如postgresql-14。sudo systemctl start postgresql手动启动,并通过sudo systemctl enable postgresql设置开机自启。