Question

 ubuntu:~$ 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-10.0 (= 10.0.3+maria-1~precise) but it 
                   is not going to be installed
 E: Unable to correct problems, you have held broken packages.

I wanted to do a "sudo apt-get upgrade", the following appeared (see below). I wanted to update MariaDB to it's latest 10.0.3 and read on https://askubuntu.com/a/18694 that's it's easier to use "sudo aptitude". Though, I pressed the wrong key, it has done the upgrade and broke MariaDB.

I am on Ubuntu 12.04 LTS x64, MariaDB 10.0 worked fine for the last three months prior to the mistake

I tried to install MariaDB 10 again, as explained there: https://downloads.mariadb.org/mariadb/repositories/

I also tried "sudo apt-get purge mysql* mariadb*" and removed it but keeping the config files (as the setup screen asked so.

My apt sources.list contains on the bottom:

 # MariaDB 10.0 repository list - created 2013-07-29 19:06 UTC
 # http://mariadb.org/mariadb/repositories/
 deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu precise main
 deb-src http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu precise main

Someone had a similar problem though with MariaDB 5.5: Installing MariaDB - Unmet dependencies, mariadb-server-5.5

Log prior to the mistake (did the mistake with aptitude though as stated above):

The following packages have been kept back:
  libmariadbclient18 libmysqlclient18 linux-headers-virtual
  linux-image-virtual linux-virtual mariadb-client-10.0
  mariadb-client-core-10.0 mariadb-server mariadb-server-10.0
  mariadb-server-core-10.0
The following packages will be upgraded:
  apt apt-transport-https apt-utils bind9-host binutils curl dnsutils
  hiphop-php libapt-inst1.4 libapt-pkg4.12 libbind9-80 libcurl3
  libcurl3-gnutls libdns81 libdrm-intel1 libdrm-nouveau1a libdrm-radeon1
  libdrm2 libisc83 libisccc80 libisccfg82 libldap-2.4-2 liblwres80
  libpython2.7 libssl-dev libssl-doc libssl1.0.0 libxml2 libxml2-dev
  linux-firmware linux-libc-dev openssl python python-minimal python2.7
  python2.7-minimal
36 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
Need to get 54.8 MB of archives.
Was it helpful?

Solution

I solved the issue the following way:

create new file in "/etc/apt/preferences.d/" named "mariadb":

Package: *
Pin: origin ftp.osuosl.org
Pin-Priority: 1000

details: https://kb.askmonty.org/en/installing-mariadb-deb-files/#pinning-the-mariadb-repository

This does Pin the MariaDB Repository and gives it a very high priority above 999 priority means it would even downgrade packages to install MariaDB.

Reason:

Oracle is issuing security update for MySQL and Ubuntu is distributing very up-to-date MySQL packages with higher version number than MariaDB. And MariaDB (it's a fork of MySQL) provides several binaries under the same name as MySQL. So pinning the MariaDB repository fixed the problem.

Thank goes to Jbboin of the official IRC channel who pointed me in the right direction!

OTHER TIPS

check your /etc/apt/sources.list , there could be some leftovers from previous installs resulting in dependecy errors. Simply remove that.

then

apt update 
apt install mariadb-server mariadb-client

I have faced same issue while installing mariadb-server in ubuntu 20. I followed below steps to resolve. And it worked.

  1. sudo apt-get upgrade
  2. sudo apt-get dist-upgrade
  3. sudo apt-get update
  4. sudo apt-get install -f
  5. sudo apt autoremove
  6. sudo apt-get install mariadb-server`

I had this same issue when trying to setup MariaDB on Ubuntu 18.04:

I was getting the error below:

The following packages have unmet dependencies: mariadb-server : Depends: mariadb-server-10.1 (>= 1:10.1.48-0ubuntu0.18.04.1) but it is not going to be installed E: Unable to correct problems, you have held broken packages

Here's how I solved it:

First, check if there are existing MariaDB packages and remove them:

sudo apt purge mariadb-server
sudo apt autoremove

Note: The version of MariaDB I setup was MariaDB 10.3, you could use the link in the reference below to check for the latest version.

Next, run the commands below to install MariaDB 10.3 from the MariaDB repository on your Ubuntu system:

sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.netcologne.de/mariadb/repo/10.3/ubuntu bionic main'

Once the key is imported and the repository added you can install MariaDB 10.3 from the MariaDB repository with:

sudo apt update
sudo apt install mariadb-server

Reference: Setting up MariaDB Repositories

That's all

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top