Ubuntu – Unmet dependencies – libstdc++6

aptdependenciespackage-management

I'm trying to install mysql but can't because of the following error:

set@set-home ~ $ sudo apt-get install mysql-server -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libstdc++6:i386 : Breaks: libstdc++6 (!= 8.1.0-5ubuntu1~14.04) but 8.2.0-9 is to be installed
 libstdc++6 : Depends: gcc-8-base (= 8.2.0-9) but 8.1.0-5ubuntu1~14.04 is to be installed
              Breaks: libboost-date-time1.54.0 but 1.54.0-4ubuntu3.1 is to be installed
              Breaks: libstdc++6:i386 (!= 8.2.0-9) but 8.1.0-5ubuntu1~14.04 is to be installed
 mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

I have tried:

  1. sudo apt-get -f install
  2. sudo apt-get -u dist-upgrade
  3. sudo apt-get autoclean
  4. sudo apt-get clean

but all this with no luck. How can I solve this?

Best Answer

Let's look at the available packages in the Ubuntu repositories for libstdc++6:

$ rmadison libstdc++6             // The rmadison command is provided by the 'devscripts' package
 libstdc++6 | 4.6.3-1ubuntu5          | precise         | amd64, armel, armhf, i386, powerpc
 libstdc++6 | 4.8.2-19ubuntu1         | trusty          | amd64, arm64, armhf, i386, powerpc, ppc64el
 libstdc++6 | 4.8.4-2ubuntu1~14.04.4  | trusty-security | amd64, arm64, armhf, i386, powerpc, ppc64el
 libstdc++6 | 4.8.4-2ubuntu1~14.04.4  | trusty-updates  | amd64, arm64, armhf, i386, powerpc, ppc64el
 libstdc++6 | 5.3.1-14ubuntu2         | xenial          | amd64, arm64, armhf, i386, powerpc, ppc64el, s390x
 libstdc++6 | 5.4.0-6ubuntu1~16.04.10 | xenial-security | amd64, arm64, armhf, i386, powerpc, ppc64el, s390x
 libstdc++6 | 5.4.0-6ubuntu1~16.04.11 | xenial-proposed | amd64, arm64, armhf, i386, powerpc, ppc64el, s390x
 libstdc++6 | 5.4.0-6ubuntu1~16.04.11 | xenial-updates  | amd64, arm64, armhf, i386, powerpc, ppc64el, s390x
 libstdc++6 | 8-20180414-1ubuntu2     | bionic          | amd64, arm64, armhf, i386, ppc64el, s390x
 libstdc++6 | 8.2.0-1ubuntu2~18.04    | bionic-updates  | amd64, arm64, armhf, i386, ppc64el, s390x
 libstdc++6 | 8.2.0-7ubuntu1          | cosmic          | amd64, arm64, armhf, i386, ppc64el, s390x
 libstdc++6 | 8.2.0-12ubuntu1         | disco           | amd64, arm64, armhf, i386, ppc64el, s390x
 libstdc++6 | 8.2.0-13ubuntu1         | disco-proposed  | amd64, arm64, armhf, i386, ppc64el, s390x

Aha. Neither of your two options, 8.1.0-5ubuntu1~14.04 nor 8.2.0-9 is from the Ubuntu repositories.

Now we know the problem: You have unwisely added non-Ubuntu sources that are providing packages that are incompatible with your release of Ubuntu. This is also called a 'version conflict' or 'held broken packages'. They are not really "broken", just wrong version...but they do break your system.

The solution is to uninstall ALL packages from that unwise source, and then to delete that source. Return your system to using packages provided by the Ubuntu repositories. Then MySQL will install.

If you don't know how to uninstall packages from a specific source, then see How can PPAs be removed? for instructions on how to install and use the ppa-purge command.