Ubuntu 20 上 mariadb-server-core-10.3 与 mariadb-server-10.3 1:10.3.30+maria~bionic 之间的冲突

Ubuntu 20 上 mariadb-server-core-10.3 与 mariadb-server-10.3 1:10.3.30+maria~bionic 之间的冲突

我正在尝试升级我的服务器,但处于一种奇怪的状态,其中 mariadb-server-core-10.3 和 mariadb-server-10.3 1:10.3.30+maria~bionic 相互冲突,并且可能涉及 mysql-server-core-5.5。

这是一台 Ubuntu 20 服务器,已经经历了几次版本升级。我怀疑一个主要问题是 MariaDB 是在它不是 Ubuntu apt 的一部分时安装的,我必须手动将源放入 /etc/apt/sources.list.d

症状:

尝试升级时,它会抱怨依赖关系并建议运行 apt --fix-broken install。当我这样做时,问题得到了很好的收集。

root@host:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libllvm11 libmariadb3 php8.0-curl php8.0-gd php8.0-mbstring php8.0-ssh2
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mariadb-server-10.3 mariadb-server-core-10.3
Suggested packages:
  mailx mariadb-test tinyca
The following packages will be upgraded:
  mariadb-server-10.3 mariadb-server-core-10.3
2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
28 not fully installed or removed.
Need to get 0 B/10.2 MB of archives.
After this operation, 717 kB disk space will be freed.
Do you want to continue? [Y/n] Y
Preconfiguring packages ...
(Reading database ... 58001 files and directories currently installed.)
Preparing to unpack .../mariadb-server-core-10.3_1%3a10.3.34-0ubuntu0.20.04.1_amd64.deb ...
Unpacking mariadb-server-core-10.3 (1:10.3.34-0ubuntu0.20.04.1) over (1:10.3.30+maria~bionic) ...
dpkg: error processing archive /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.34-0ubuntu0.20.04.1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/my_print_defaults', which is also in package mariadb-server-10.3 1:10.3.30+maria~bionic
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
dpkg: regarding .../mariadb-server-10.3_1%3a10.3.34-0ubuntu0.20.04.1_amd64.deb containing mariadb-server-10.3:
 mariadb-server-10.3 conflicts with mysql-server-core-5.5
  mariadb-server-core-10.3 provides mysql-server-core-5.5 and is present and installed.

但是 mysql-server-core-5.5 似乎没有安装。

root@host:~# apt list --installed | grep mysql

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libdbd-mysql-perl/focal,now 4.050-3 amd64 [installed,auto-removable]
libmysqlclient21/focal-updates,focal-security,now 8.0.29-0ubuntu0.20.04.3 amd64 [installed,automatic]
mysql-common/now 1:10.3.30+maria~bionic all [installed,local]
php7.4-mysql/focal,now 1:7.4.30-3+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-mysql/focal,now 1:8.0.20-2+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
postfix-mysql/focal-updates,now 3.4.13-0ubuntu1.2 amd64 [installed]

而且似乎其他软件包依赖于 mysql-common。mysql-client 和 mysql-server 均未安装,如果我尝试删除 mysql-common,则会收到以下信息:

root@host:~# apt-get purge mysql-common
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 (>= 5.5) but it is not going to be installed
 mariadb-common : Depends: mysql-common (>= 5.6.25) but it is not going to be installed
 mariadb-server : Depends: mariadb-server-10.3 (>= 1:10.3.34-0ubuntu0.20.04.1) but 1:10.3.30+maria~bionic is to be installed

所以如果我没看错最后一行,那么有某种 mariadb-server-10.3 和 1:10.3.30+maria~bionic?我在 /etc/apt/sources.list.d 中确实有 mariadb 源。

mariadb.list
mariadb.list.distUpgrade
mariadb.list.save

mariadb.list 具体如下:

# MariaDB Server
# To use a different major version of the server, or to pin to a specific minor version, change URI below.
# deb [arch=amd64,arm64] https://downloads.mariadb.com/MariaDB/mariadb-10.3/repo/ubuntu focal main # disabled on upgrade to focal

deb [arch=amd64,arm64 lang=none target-=CNF] https://downloads.mariadb.com/MariaDB/mariadb-10.3/repo/ubuntu bionic main/debug

# MariaDB MaxScale
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
# deb [arch=amd64] https://dlm.mariadb.com/repo/maxscale/latest/apt focal main # disabled on upgrade to focal

# MariaDB Tools
# deb [arch=amd64] http://downloads.mariadb.com/Tools/ubuntu focal main # disabled on upgrade to focal

关于如何安全地修复此问题,您有什么想法吗?谢谢!

答案1

看起来问题确实是很久以前安装的手动 repo 与较新的 Ubuntu 版本捆绑的 MariaDB 包之间存在冲突。

我采取了以下步骤 - 1. 手动 apt-get 删除所有 MariaDB 10.3 软件包。(通过 apt list --installed | grep mariadb)。如果出现错误,可能是操作顺序问题。先删除服务器软件包,然后删除客户端。2. 删除 /etc/apt/source.list.d 中的所有 mariadb* 条目。3) 使用 apt-get 从官方存储库安装 MariaDB。(sudo apt update、sudo apt install mariadb-server、sudo mysql_secure_installation)。

此过程不会删除数据文件,因此重新安装时您的数据库和所有权限仍然存在。

相关内容