鉴于
Ubuntu 22.04
我尝试像这样安装 PostgreSQL 9.6(我需要这个版本):
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.6
但出现错误:
sudo apt-get install postgresql-9.6
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package postgresql-9.6
E: Couldn't find any package by glob 'postgresql-9.6'
E: Couldn't find any package by regex 'postgresql-9.6'
使用评论中的建议后我收到错误:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
postgresql-9.6 is already the newest version (9.6.24-3.pgdg22.04+1).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
答案1
您需要添加来自 Postgres 的存储库,因为这些版本不在 Ubuntu 存储库中。
首先,导入 GPG 密钥。
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
接下来,添加 repo。
echo "deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
然后您就可以安装您想要的版本了。
sudo apt update
sudo apt install postgresql-9.6