当 Apt 报告 MariaDB 有未满足的依赖项或损坏的包时安装 MariaDB

And*_*eas 11 apt mariadb software-installation

我已经尝试了一切在这个干净的 Ubuntu 安装上安装 MariaDB,但我一直收到这个错误,

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:
mariadb-server : Depends: mariadb-server-5.5 (= 5.5.33a+maria-1~saucy) 
but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

我已按照本指南尝试安装它, http://www.unixmen.com/install-lemp-server-nginx-mysql-mariadb-php-ubuntu-13-10-server/

而且我还遵循了 13.10 的 MariaDB 下载页面上的“官方”指南 https://downloads.mariadb.org/mariadb/repositories/

但似乎没有任何效果。

编辑 1

我已经尝试了添加 PPA 后如何解决未满足的依赖项?以及如何安装 MariaDB?但它仍然给我上面发布的错误。

这是一个全新的 Ubuntu 安装,几乎没有安装任何东西。

编辑 2

所有复选框都是更新中的票证。我跑了:

sudo apt-get update && sudo apt-get -f install mariadb-server-5.5"=5.5.33a+maria-1~saucy"
Run Code Online (Sandbox Code Playgroud)

它给了我这个错误:

The following packages have unmet dependencies:
mariadb-server-5.5 : Depends: mariadb-client-5.5 (>= 5.5.33a+maria-1~saucy) 
but it is not going to be installed
Depends: mariadb-server-core-5.5 (>= 5.5.33a+maria-1~saucy) 
but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

cha*_*kes 17

查看Mariadb 和 Ubuntu Debian 存储库之间的版本不匹配

官方 Ubuntu 或 Debian 存储库中 mysql-common 或 libmysqlclient 的版本号很少高于 MariaDB 存储库中的版本号,但这种情况已经发生。每当它出现时,都是因为发行版存储库中 MySQL 版本中存在的错误的关键错误修复版本,但这些错误已在 MariaDB 存储库中的 MariaDB 版本中修复。

如果在您尝试安装 MariaDB 时存在上述情况,您将收到如下错误:
The following packages have unmet dependencies:
mariadb-server : Depends: mariadb-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)
解决此问题的一种方法是指定要安装的两个软件包的确切版本。为此,首先要确定受影响软件包的完整版本号。一个简单的方法是使用“apt-cache show”:
apt-cache show mysql-common | grep Version
apt-cache show libmysqlclient18 | grep Version
Run Code Online (Sandbox Code Playgroud)

这是撰写本文时的情况,因为版本号显示为:

Version: 5.5.34-0ubuntu0.13.10.1
Version: 5.5.34+maria-1~saucy
Run Code Online (Sandbox Code Playgroud)

MariaDB 页面给出了两种解决方案。

第一个解决方案:指定包版本

对于上述每一项,您都会获得一个版本列表。MariaDB 存储库中的版本字符串中将包含“mariadb”并且是您想要的。有了版本号,您就可以通过显式指定版本号来安装 MariaDB,如下所示:
apt-get install mariadb-server-5.5 mariadb-client-5.5 \
libmysqlclient18=<version-number> \
mysql-common=<version-number>
Run Code Online (Sandbox Code Playgroud)

这是

apt-get install mariadb-server-5.5 mariadb-client-5.5 \
 libmysqlclient18=5.5.34+maria-1~saucy \
 mysql-common=5.5.34+maria-1~saucy
Run Code Online (Sandbox Code Playgroud)

注意:更新到 5.5.34 以反映截至 2014.01.28 的当前版本 [RealPariah] 安装后,您需要保留软件包直到版本号恢复同步。

MariaDB 安装后,只要版本号问题存在,`apt-get dist-upgrade` 就会尝试删除 MariaDB,以安装“升级”的 libmysqlclient 和 mysql-common 包。为了防止这种情况发生,您可以保留它们,以便 apt 不会尝试升级它们。为此,请打开终端,使用 `sudo -s` 成为 root,然后输入以下内容:
echo libmysqlclient18 hold | dpkg --set-selections
echo mysql-common hold | dpkg --set-selections
Run Code Online (Sandbox Code Playgroud)
保留将阻止您升级 MariaDB,因此当您要删除保留时,请打开终端,使用“sudo -s”成为 root,然后输入以下内容:
echo libmysqlclient18 install | dpkg --set-selections
echo mysql-common install | dpkg --set-selections
Run Code Online (Sandbox Code Playgroud)
然后您就可以正常升级 MariaDB(例如使用`sudo apt-get update; sudo apt-get upgrade`)。

我如何知道版本号何时再次匹配?

您可以通过在MariaDB.org上注册新版本的电子邮件警报来跟踪 MariaDB 版本号。根据该网站,它是一个low-traffic announce-only list.

此外,当软件包版本再次同步时,您应该不会在 apt 中看到一条消息,即只会保留 2 个保留的软件包,但将保留所有 mariadb 软件包:

The following packages have been kept back:
libmariadbclient18 libmysqlclient18 linux-generic linux-headers-generic
linux-image-generic mariadb-client-5.5 mariadb-client-core-5.5
mariadb-server mariadb-server-5.5 mariadb-server-core-5.5 mysql-common
Run Code Online (Sandbox Code Playgroud)

这表明包号重新同步,也可以在突触或类似工具中检查。

第二种解决方案:固定 MariaDB 存储库

您可以做的另一件事是固定您使用的 MariaDB 存储库。这是通过在 `/etc/apt/preferences.d/` 下创建一个包含以下内容的文件来完成的:
Package: *
Pin: origin <mirror-domain>
Pin-Priority: 1000
Run Code Online (Sandbox Code Playgroud)

替换<mirror-domain>为您使用的 MariaDB 镜像的域名。例如,ftp.osuosl.org。有了 pin 文件,您的 MariaDB 存储库中的包将优先于系统存储库中的包。

您可以在System Settings >> Software & Updates 中找到您使用的镜像名称,或者如果您使用的是其他风格的 Ubuntu、Synaptic >> Settings >> Repositoriescat /etc/apt/sources.list.

Pin-Priority这种情况下需要为大于或等于1000,其中causes a version to be installed even if this constitutes a downgrade of the package

(有关man 5 apt_preferences其他情况下的选项的更多信息,请参见。)

命名固定首选项文件

Note that the file in the /etc/apt/preferences.d directory are parsed in alphanumeric ascending order and need to obey the following naming convention:

The files have either no or "pref" as filename extension and only contain alphanumeric, hyphen (-), undescore (_), and period (.) characters. Otherwise APT will print a notice that it has ignored a file...

(来源:man 5 apt_preferences

因此,名称本身并不重要,但一个好的名称应该是类似50_mariadb. 这可以识别所涉及的包,并允许其他固定首选项文件按处理顺序轻松放置在此文件之前或之后。