无法在 Ubuntu 18.04 中安装 postgreSQL 9.6

web*_*son 18 apt postgresql 18.04

我正在尝试通过 Ubuntu 软件中心在 Ubuntu 18.04 中安装 postgreSQL 9.6 并从终端输入

sudo apt-get install postgresql-9.6

根据官方文档https://www.postgresql.org/download/linux/ubuntu/

Create the file /etc/apt/sources.list.d/pgdg.list and add a line for the repository
Run Code Online (Sandbox Code Playgroud)

deb http://apt.postgresql.org/pub/repos/apt/bionic-pgdg main

Import the repository signing key, and update the package lists

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |   sudo apt-key add -
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

要安装的版本是10

有什么帮助吗?

提前致谢。

postgresql:
Run Code Online (Sandbox Code Playgroud)

已安装:(无)候选:10+191.pgdg18.04+1 版本表:10+191.pgdg18.04+1 500 500 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 包 500 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main i386 包 10+190 500 500 http://gr.archive.ubuntu.com/ubuntu bionic/main amd64 包 500 http ://gr.archive.ubuntu.com/ubuntu bionic/main i386 软件包

如果我检查 postgresql 文件夹在哪里,似乎我有两个版本,9.6 和 10

/usr/lib/postgresql

web*_*son 34

几个月后,我不得不从头开始擦除并安装,因此为了安装 postgresql 9.6,我遵循了以下步骤:

重要说明:如果您已经安装了 postgresql 10 并且想要 9.6,则需要完全删除 postgresql 10 然后手动安装 postgresql 9.6,因此请按照方法 2

方法一

第1步

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'  
Run Code Online (Sandbox Code Playgroud)

第2步

wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - 
Run Code Online (Sandbox Code Playgroud)

第 3 步。

sudo apt-get update  
sudo apt-get upgrade 
sudo apt-get install postgresql-9.6 
Run Code Online (Sandbox Code Playgroud)

方法二

为了安装已经安装了 postgres 10 或其他与 9.6 不同的版本的 postgres 9.6,您首先需要按照以下步骤完全卸载 postgresql(任何版本和文件相关)。

sudo apt-get --purge remove postgresql

dpkg -l | grep postgres (to look for postgresfiles in the system)

sudo rm -rf postgresql ... (remove all the files that appeared in the list after running the previous command)
Run Code Online (Sandbox Code Playgroud)

最后使用下一个命令手动安装 postgreSQL:

sudo apt-get install postgresql-9.6
Run Code Online (Sandbox Code Playgroud)

我希望它可以帮助可能有同样问题的人。