EC2 中的 apt 命令采用了错误的版本

Wrong version taken in apt command in EC2

我们正在尝试安装 libmysqlclient-dev 并使用了这个命令:

sudo apt-get install libmysqlclient-dev -y

我们收到以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libmysqlclient21
The following NEW packages will be installed:
  libmysqlclient-dev libmysqlclient21
0 upgraded, 2 newly installed, 0 to remove and 12 not upgraded.
Need to get 2,892 kB of archives.
After this operation, 17.8 MB of additional disk space will be used.
Ign:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient21 amd64 8.0.28-0ubuntu0.20.04.3
Err:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient21 amd64 8.0.28-0ubuntu0.20.04.3
  404  Not Found [IP: 185.125.190.36 80]
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient-dev amd64 8.0.28-0ubuntu0.20.04.3
Err:2 http://security.ubuntu.com/ubuntu focal-updates/main amd64 libmysqlclient-dev amd64 8.0.28-0ubuntu0.20.04.3
  404  Not Found [IP: 185.125.190.36 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/libmysqlclient21_8.0.28-0ubuntu0.20.04.3_amd64.deb  404  Not Found [IP: 185.125.190.36 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/libmysqlclient-dev_8.0.28-0ubuntu0.20.04.3_amd64.deb  404  Not Found [IP: 185.125.190.36 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

我们同时使用了 apt-get update--fix-missing 选项。我们遇到了同样的错误。

然后我们使用 sudo apt-cache policy libmysqlclient-dev:

列出了可用的版本

我们得到了:

libmysqlclient-dev:
  Installed: (none)
  Candidate: 8.0.28-0ubuntu0.20.04.3
  Version table:
     8.0.28-0ubuntu0.20.04.3 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     8.0.19-0ubuntu5 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

我们去了http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/

我们使用 lsb_release -a 获得了 linux 的版本:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

然后我们尝试使用 sudo apt-get install libmysqlclient-dev=8.0.28-0ubuntu0.20.04.4 -y:

强制安装可用版本

我们得到了:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Version '8.0.28-0ubuntu0.20.04.4' for 'libmysqlclient-dev' was not found

我们如何安装这个包?

尝试:

1] 编辑您的 /etc/apt/sources.list

2]评论或删除全部内容

3] 粘贴这个

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
#
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
#
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
#
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
#
deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner
  1. apt clean all && apt update

它们是focal的官方包。 希望有用!