我正在尝试安装mysql-server
。Ubuntu 20.04 LTS
但是我收到此错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libmysqlclient21 : Depends: mysql-common (>= 8.0.23-1ubuntu20.04)
Depends: mysql-community-client-plugins (= 8.0.23-1ubuntu20.04) but it is not going to be installed
mysql-server : Depends: mysql-community-server (= 8.0.23-1ubuntu20.04) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我在网上找到了各种答案,这些问题非常相似,但没有一个能给出有效的答案。我从找到的答案中尝试了很多终端命令,但都没有用,我在这里提到了几个。
sudo apt --fix-broken install sudo apt reinstall sudo dpkg --configure --force-overwrite -a sudo apt-get clean sudo dpkg --configure -a sudo apt purge mysql-server sudo apt purge libmysqlclient21 sudo dpkg-i ~/Downloads/mysql-apt-config_0.8.16-1_all.deb sudo dpkg -i mysql-{common,community-client,client,community-server,server)_*.deb sudo apt-get autoremove sudo apt-get install mysql-server
几乎在每一个中我都会遇到错误。并非所有的错误都相同。但错误不会停止。
我找到了一个解决方案,它说要安装aptitude
或synaptic package manager
修复这些。但apt-get install
每次安装时都会出错。
被推荐没有人我尝试了一下apt-cache policy mysql-server
并得到了这个输出:
mysql-server:
Installed: (none)
Candidate: 8.0.23-1ubuntu20.04
Version table:
8.0.23-1ubuntu20.04 500
500 http://repo.mysql.com/apt/ubuntu focal/mysql-8.0 amd64 Packages
8.0.23-0ubuntu0.20.04.1 500
500 http://qa.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
500 http://qa.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
8.0.19-0ubuntu5 500
500 http://qa.archive.ubuntu.com/ubuntu focal/main amd64 Packages
500 http://qa.archive.ubuntu.com/ubuntu focal/main i386 Packages
答案1
如果您遇到依赖项无限循环的问题,导致无法全新安装或删除现有软件包,这里有一个经过反复试验后对我有用的解决方案:
- 首先运行以下命令:
sudo apt --fix-broken purge mysql-server
此命令可能会显示需要解决的其他依赖关系。
- 记下输出中显示的其他依赖项。然后,将它们添加到命令中并重新运行。重复此过程,直到所有有问题的软件包都包含在单个命令中。例如,如果命令最初显示其他依赖项,如
mysql-common
、、等,您可以逐渐构建命令,如下所示mysql-cluster-community-client-core
:libmysqlclient21
sudo apt --fix-broken purge mysql-server mysql-common mysql-cluster-community-client-core libmysqlclient21
继续向命令添加更多依赖项并重新运行它,直到包含并删除所有有问题的包。
以下是一次性删除所有有问题的包的最终命令:
sudo apt --fix-broken purge mysql-community-client-plugins mysql-common mysql-cluster-community-client-core libmysqlclient21 mysql-common mysql-cluster-community-client-core mysql-cluster-community-client mysql-cluster-community-server mysql-client mysql-server
答案2
(解决了)
我意识到了这个问题。当我尝试单独安装两个时,mysql-common
它mysql-community-client-plugins
显示另一个未安装且是必需的。这意味着当我尝试时sudo apt install mysql-common
它显示
Depends: mysql-community-client-plugins
反之亦然。
因此,我用一个命令安装了这两个命令,例如
sudo apt install mysql-community-client-plugins mysql-common
并且都安装成功。我mysql-server
稍后安装,它也安装成功并且mysql
运行良好。