Debian不使用Docker安装指定版本的PostgreSQL

26 年 1 月 25 日 星期日 (已编辑)
144 字
1 分钟

https://apt-archive.postgresql.org

设置PGP KEY

sudo mkdir -p /usr/share/keyrings

curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| sudo gpg --dearmor -o /usr/share/keyrings/postgresql-archive.gpg

添加PGSQL源(旧版本)

UBUNTU_CODENAME="$(lsb_release -cs)"

sudo tee /etc/apt/sources.list.d/pgdg-archive.sources > /dev/null <<EOF
Types: deb
URIs: https://apt-archive.postgresql.org/pub/repos/apt
Suites: ${UBUNTU_CODENAME}-pgdg-archive
Components: main
Signed-By: /usr/share/keyrings/postgresql-archive.gpg
EOF

sudo apt update

查找版本号

apt-cache madison postgresql-15 | grep 15.6
apt-cache madison postgresql-client-15 | grep 15.6 

输出示例

root@playground /e/a/sources.list.d# apt-cache madison postgresql-15 | grep 15.6
postgresql-15 | 15.6-1.pgdg130+1 | https://apt-archive.postgresql.org/pub/repos/apt trixie-pgdg-archive/main amd64 Packages

root@playground /e/a/sources.list.d# apt-cache madison postgresql-client-15 | grep 15.6
postgresql-client-15 | 15.6-1.pgdg130+1 | https://apt-archive.postgresql.org/pub/repos/apt trixie-pgdg-archive/main amd64 Packages

安装

sudo apt install -y \
  postgresql-15=15.6-1.pgdg22.04+1 \
  postgresql-client-15=15.6-1.pgdg22.04+1

替换=后面的 15.6-1.pgdg22.04+1 为上一步输出的版本号

查询安装的版本

dpkg -l | egrep 'postgresql-(15|client-15|contrib-15)|postgresql-(client-)?common' | awk '{print $2, $3}'
psql --version

文章标题:Debian不使用Docker安装指定版本的PostgreSQL

文章作者:violet

文章链接:https://www.vio.vin/posts/debian-bu-shi-yong-docker-an-zhuang-zhi-ding-ban-ben-de-postgresql[复制]

最后修改时间:


商业转载请联系站长获得授权,非商业转载请注明本文出处及文章链接,您可以自由地在任何媒体以任何形式复制和分发作品,也可以修改和创作,但是分发衍生作品时必须采用相同的许可协议。
本文采用CC BY-NC-SA 4.0进行许可。