安装MariaDB - 未满足的依赖,mariadb-server-5.5

30

我正在尝试在Ubuntu 12.04 LTS上安装MariaDB。

我按照https://askubuntu.com/questions/64772/how-to-install-mariadb提供的说明以及从MariaDB.org下载时出现的说明进行了操作。

最后一步是sudo apt-get install mariadb-server,返回:

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:
 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.

依赖问题是一个公认的问题(https://mariadb.atlassian.net/browse/MDEV-3882),但我相信损坏的软件包阻止了我解决这个问题。

如果我尝试安装libmariadbclient18,我会得到以下信息:

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:
 libmariadbclient18 : Depends: libmysqlclient18 (= 5.5.30-mariadb1~precise) but 5.5.31-0ubuntu0.12.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

我尝试使用sudo apt-get install -f修复损坏的软件包,但我仍然无法安装mariadb-server或libmariadbclient18。


8个回答

35
sudo apt-get install libmysqlclient18=5.5.30-mariadb1~precise mysql-common=5.5.30-mariadb1~precise
sudo apt-get install mariadb-server

第一个操作是将 Ubuntu 端升级的两个 MySQL 库回滚到旧版本的 MariaDB 库。第二个操作可以正常进行。

这些软件包被删除是因为运行了类似于 apt-get dist-upgrade 的命令。图形界面实际上会警告您出现问题。

为了防止此问题再次出现,请通过在 /etc/apt/preferences.d 中创建文件来告诉 apt 通过固定版本(pinning)方式优先使用 MariaDB 仓库。

$ cat /etc/apt/preferences.d/MariaDB.pref
Package: *
Pin: origin <mirror-domain>
Pin-Priority: 1000

另外,如果您需要编译任何东西(如Ruby宝石),请确保安装libmariadbclient-dev


谢谢,问题已解决。我只有CLI,无法使用GUI。 - Courtney Miles
CLI(apt-get)在某个时候应该也会在apt-get upgrade上发出警告,列出“以下软件包已被保留”的列表。另一方面,我不知道aptitude,但有时我觉得它试图过分地满足你的愿望。 - Lloeki
对于 Ubuntu 13.10(Saucy Salamander),请使用 sudo apt-get install libmysqlclient18=5.5.33a+maria-1~saucy mysql-common=5.5.33a+maria-1~saucy mariadb-server mariadb-client - absynce
我应该在 /etc/apt/preferences.d 使用什么文件扩展名? - Gabriel Mazetto
看我们的服务器,使用了.pref,但我不知道它是否真的很重要。 - Lloeki

10

我做了类似于 @Lloeki 的事情

$ sudo apt-get purge libmariadbclient18 mariadb-server mariadb-client-5.5 libmysqlclient18 mysql-common```

然后查找要安装的候选项并重新安装它:

$ apt-cache policy libmysqlclient18 | grep -i quantal 
Installed: 5.5.30-mariadb1~quantal
*** 5.5.30-mariadb1~quantal 0
    500 http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu/ quantal/main amd64 Packages
$ apt-cache policy mysql-common | grep -i quantal 
Installed: 5.5.30-mariadb1~quantal
*** 5.5.30-mariadb1~quantal 0
    500 http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu/ quantal/main amd64 Packages
$ 
$ sudo apt-get install libmysqlclient18=5.5.30-mariadb1~quantal mysql-common=5.5.30-mariadb1~quantal mariadb-server mariadb-client

...
 * Stopping MariaDB database server mysqld                                                              [ OK ] 
130428 13:19:40 [Note] Plugin 'InnoDB' is disabled.
130428 13:19:40 [Note] Plugin 'FEEDBACK' is disabled.

我收到了“插件已禁用”警告,但在使用sudo service mysql restart重启mysql并安装了我的SQL后,InnoDB似乎正常了,show create table mytable显示了预期的ENGINE=InnoDB DEFAULT CHARSET=utf8


我使用相同的语句在Ubuntu 13.04上解决了相同的问题。谢谢。 - mehdix

4

@Lloeki提供的解答对我来说不再适用,因为所提到的版本对我不可用,导致出现以下错误:

E: Version '5.5.30-mariadb1~precise' for 'libmysqlclient18' was not found

为了解决这个问题,你需要找到一个正确的版本:
你可以通过 aptitude versions libmysqlclient18 获取可用版本列表。对于我的系统,它看起来像是这样:
Package libmysqlclient18:
[...]
p   5.5.31+maria-1~precise                                         <NULL>                                      1000
i   1:5.5.32-rel31.0-549.precise                                   <NULL>                                      500
[...]    

有几行文本,但只显示相关的行。

带有i的行是当前安装的版本,建议的5.5.30-mariadb1~precise没有行。但是有另一个看起来很有前途的候选项。请注意,这与我的情况一样,但对你可能不同(随时间变化)。

在此示例中,您可以继续如下操作:

sudo apt-get install libmysqlclient18=5.5.31+maria-1~precise

在此之后,安装程序将选择客户端mariadb-common,您可以继续进行:

 sudo apt-get install mariadb-server

没有原帖作者的错误。

4

@yuvilio说的对:

$ sudo apt-get install libmysqlclient18=5.5.30-mariadb1~quantal mysql-common=5.5.30-mariadb1~quantal mariadb-server mariadb-client

这个命令适用于12.04、12.10和13.04(以及LinuxMint 14)。

显然,MariaDB对内核更新的敏感度比较高,如果内核更新到3.5.0-25或更高版本,则使用“sudo apt-get install mariadb-server”安装MariaDB可能会受到影响。

@yuvilio提到插件“InnoDB”和“FEEDBACK”被禁用了,但是在此安装后InnoDB可以正常使用。

这很有道理,因为MariaDB将XTRA-DB作为InnoDB的替代品。Presumably MariaDB也有一个新的feedback模块(他们希望MariaDB feedback发送到mariadb.org而不是Oracle/mySQL)。


2

让我分享一下我是如何在我的情况下解决问题的(Ubuntu 14.04)。

我遇到了错误

$ sudo apt-get install mariadb-server-5.5
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:
 mariadb-server-5.5 : Depends: mariadb-client-5.5 (>= 5.5.41+maria-1~trusty) but it is not going to be installed
                      Depends: mariadb-server-core-5.5 (>= 5.5.41+maria-1~trusty) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

解决方案:

步骤1:sudo apt-get install libmysqlclient18

步骤2:sudo apt-get install mariadb-server

注意事项:

  • 我是按照这些指示进行安装的。
  • 我之前没有安装MySQL。

这对我没有用。我安装了第一个,但第二个调用仍然失败。Ubuntu 14.04。 - CoderGuy123

2

尝试

sudo dpkg --remove --force-remove-reinstreq BROKEN_PACKAGE

我已经尝试过将BROKEN_PACKAGE替换为libmysqlclient18,但它显示未安装。我该如何确定损坏的软件包是什么? - Courtney Miles
尝试使用命令 "dpkg --get-selections | less" 并查找任何mysql软件包,卸载它们然后再次尝试。 - dza
1
谢谢。我用grep搜索了Maria、MySQL、SQL和DB,但没有找到任何结果。我想知道如何解决这个问题,但不幸的是,重新启动服务器会更快。 - Courtney Miles
好的,成功了:sudo dpkg --ignore-depends=libmariadbclient18 --ignore-depends=php5-mysql --ignore-depends=libqt4-sql-mysql --remove --force-remove-reinstreq libmysqlclient18sudo dpkg --ignore-depends=libmariadbclient18 --ignore-depends=php5-mysql --ignore-depends=libqt4-sql-mysql --purge --force-remove-reinstreq libmysqlclient18 - Christophe Eblé
谢谢,伙计。这对我有用,实际上需要先删除损坏的软件包,然后再使用 sudo apt-get install mariadb-server 重新安装。 - Aditya Kresna Permana

2

我不知道这是否对任何人有帮助,但我在安装Mariadb 10时遇到了问题,并得到了一个错误消息,导致我来到了这个页面,但是我尝试的所有方法都没有帮助。

最终,我意识到我的 /tmp 目录归属于 root 用户,其他用户无法对其进行写入。我解决了这个问题,然后执行了以下操作:

apt-get remove mariadb-server

我尝试重新安装,但是卸载失败,所以我删除了/var/lib/mysql,然后尝试了以下操作:

apt-get remove mariadb-server

再次运行,实际上安装了Mariadb服务器并使其运行...

现在它可以正常工作。


0

我成功安装了Mariadb,方法是先删除所有的mysql包,然后运行以下命令:

    sudo apt-get install mariadb-server-5.5 mariadb-client-5.5 \
    mariadb-server-core-5.5 mariadb-common mariadb-server \
    libmariadbclient18 libdbd-mysql-perl mariadb-client-core-5.5 \
    libmysqlclient18=5.5.30-mariadb1~quantal \
    mysql-common=5.5.30-mariadb1~quantal

我不确定是否需要先删除mysql。


你是提问者吗?如果是的话,你应该将你的账户链接起来。 - luser droog
很不幸,我没有安装任何mysql包可以卸载 :( 而且由于我无法识别的损坏包,你的命令也无法运行。 - Courtney Miles

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接