当Apt报告MariaDB具有未满足的依赖关系或损坏的包时,安装MariaDB

我已经尝试了在这个干净的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. 

我已按照本指南尝试安装它, 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" 

它给了我这个错误:

 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. 

请参阅Mariadb和Ubuntu Debian存储库之间的版本不匹配

在官方的Ubuntu或Debian存储库中,mysql-common或libmysqlclient的版本号比在MariaDB存储库中更高,但很少见,但它已经发生了。 无论什么时候出现,都是因为发布存储库中MySQL版本中存在的bug存在严重错误修复版本,但已经在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. 

解决此问题的方法是指定要安装的两个软件包的确切版本。 为此,请首先确定受影响的包的完整版本号。 一个简单的方法是使用’apt-cache show’:

 apt-cache show mysql-common | grep Version apt-cache show libmysqlclient18 | grep Version 

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

 Version: 5.5.34-0ubuntu0.13.10.1 Version: 5.5.34+maria-1~saucy 

MariaDB页面提供了两种解决方案。

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

对于上述每一项,您将获得一个版本列表。 MariaDB存储库中的那些将在版本字符串中具有“mariadb”并且是您想要的。 有了版本号,您就可以通过显式指定版本号来安装MariaDB,如下所示:

 apt-get install mariadb-server-5.5 mariadb-client-5.5 \ libmysqlclient18= \ mysql-common= 

是的

 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 

注意:更新到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 

保留将阻止您升级MariaDB,因此当您要删除保留时,打开终端,使用’sudo -s’成为root,然后输入以下内容:

 echo libmysqlclient18 install | dpkg --set-selections echo mysql-common install | dpkg --set-selections 

然后,您将能够正常升级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 

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

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

您可以做的另一件事是固定您使用的MariaDB存储库。 这是通过使用以下内容在`/ etc / apt / preferences.d /`下创建一个文件来完成的:

 Package: * Pin: origin  Pin-Priority: 1000 

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

您可以在系统设置>>软件和更新中找到您正在使用的镜像名称,或者如果您使用的是另一种Ubuntu, Synaptic >>设置>>存储库cat /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 。 这标识了所涉及的包,并允许在处理顺序中的此文件之后轻松放置其他固定首选项文件。

我在Ubuntu 14.10中从MySQL升级到Maria DB时遇到了类似的问题。 也就是说我会被困住

  libmysqlclient18:amd64 10.0.16+maria-1~utopic (Multi-Arch: no) is not co-installable with libmysqlclient18 which has multiple installed instances 

在遵循这些建议无济于事之后,以下内容对我有很大帮助: 如何通过JournalXtra 在Ubuntu Server中用MariaDB替换MySQL 。

编辑/ var / lib / dpkg / status并删除libmysqlclient18的两个实例,如下所示:

 Package: libmysqlclient18 Status: deinstall ok config-files Priority: optional Section: libs Installed-Size: 3392 Maintainer: Ubuntu Developers  Architecture: i386 Multi-Arch: same Source: mysql-5.5 Version: 5.5.40-0ubuntu1 Config-Version: 5.5.40-0ubuntu1 Depends: mysql-common (>= 5.5.40-0ubuntu1), libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), zlib1g (>= 1:1.1.4) Pre-Depends: multiarch-support Description: MySQL database client library 

MySQL是一个快速,稳定和真正的多用户,multithreadingSQL数据库服务器。 SQL(结构化查询语言)是世界上最流行的数据库查询语言。 MySQL的主要目标是速度,稳健性和易用性。 。 该软件包包括客户端库。 主页: http : //dev.mysql.com/原始维护者:Debian MySQL维护者

允许我以后顺利安装MariaDB。

 sudo apt-get install mariadb-server 

注意 :在此解决方案工作之前,我在多次尝试删除libmariadbclient18和libmysqlclient18后确实到了这里。 我无法通过apt-get问题,直到这两个被删除,因为在我尝试任何其他修复之前它们被报告为破损包。