在升级到 21.04 LTS 之前尝试更新我的系统时,MySQL 出现了无法更新或修复的错误,因此我将其清除:
sudo apt purge mysql-server-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
mysql-server-8.0*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 555934 files and directories currently installed.)
Purging configuration files for mysql-server-8.0 (8.0.17-0ubuntu2) ...
Processing triggers for systemd (246.6-1ubuntu1.3) ...
但是,现在它不会重新安装。
sudo apt-get install mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mysql-common : Conflicts: mysql-client-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
Conflicts: mysql-client-core-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
有些东西显然坏了,但不知道怎么办?
以下是基于评论的一些附加输出:
Sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu groovy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu groovy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu groovy-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
sudo apt clean
sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sudo apt update && sudo apt upgrade
Hit:1 http://archive.ubuntu.com/ubuntu groovy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu groovy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu groovy-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sudo dpkg --configure -a
sudo apt install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
然后尝试安装 mysql-client ,尽管没有安装它,但它在 mysql-client 上出现错误:
sudo apt install mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mysql-common : Conflicts: mysql-client-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
Conflicts: mysql-client-core-8.0 but
8.0.25-0ubuntu0.20.10.1 is to be installed
E: Unable to correct problems, you have held broken packages.
其他尝试:
sudo apt install mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mysql-common : Conflicts: mysql-client-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
Conflicts: mysql-client-core-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
E: Unable to correct problems, you have held broken packages.
sudo apt purge mysql-client-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'mysql-client-8.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sudo apt purge mysql-client-core-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'mysql-client-core-8.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
似乎在告诉我未安装 MySQL,但它的安装存在冲突!我该如何解决这个难题?
这有时可以通过清理
apt
一下来解决。在终端中,试试这个:现在尝试安装 MySQL 客户端。如果错误仍然存在,那么您可能需要“修复”安装:
现在您应该可以安装客户端了:
注意:虽然您已经删除了 MySQL 服务器,但仍有一些文件在
/var/lib/mysql
. 这些是卸载后故意留下的。如果您不需要任何以前可用的数据库,请随意删除此目录。您可能还会/etc/mysql
留下来,如果您不再需要配置文件,也可以将其删除。从 Ubuntu (18.04 和更新版本) 清理 MySQL
如果 MySQL 拒绝正常运行,那么您可能需要按照以下步骤将其从系统中彻底清除:
apt purge
它们会脱离系统: 对 MariaDB 执行相同的操作:mysql
而无需请求确认。请务必小心谨慎地使用它。delgroup
再删除。只要您的机器上没有配置某种 XAMPP 系统,这应该完全消除您机器上的数据库引擎。