It seems that Ubuntu 16.04 is coming with MySQL 5.7, however I need to install 5.6.

When I try to install it explicitly sudo apt-get install mysql-server-5.6 I get the following error:

Package mysql-server-5.6 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  mysql-community-server:i386 mysql-common:i386 mysql-community-server mysql-common percona-xtradb-cluster-server-5.6:i386 percona-server-server-5.6:i386 mysql-testsuite-5.7:i386
  mariadb-server-10.0:i386 percona-xtradb-cluster-server-5.6 percona-server-server-5.6 mysql-testsuite-5.7 mariadb-server-10.0 mysql-server-core-5.7:i386 mysql-server-5.7:i386 mysql-server-core-5.7
  mysql-server-5.7

Is there any way to install 5.6?

  • That mysql 5.7.12 is a RAM hog. – dibs Jun 28 '16 at 0:44

I used the following approach:

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
sudo apt-get update
sudo apt install mysql-server-5.6 mysql-client-5.6

If an error occurs during the execution of the last command take a look at the comment section of this answer.

  • 8
    You may need to sudo rm /var/lib/mysql/debian-5.7.flag or it will abort with Sub-process /usr/bin/dpkg returned an error code (1) – xxjjnn Jul 7 '16 at 18:03
  • 2
    the mysql service doesn't start properly. using 'systemctl status mysql.service' I get 'Failed to start LSB: Start and stop the mysql database server daemon'. Is this because the Trusty repo uses upstart and 5.7 uses systemd ? – jowan sebastian Aug 3 '16 at 15:31
  • 1
    @jowansebastian - Did you ever find out why this was happening? I'm having a similar error. – Barrie Reader Sep 21 '16 at 14:25
  • @BarrieReader no sorry, I created a centos VM for what I was doing and got it working in there fine. – jowan sebastian Sep 21 '16 at 20:23
  • +1. Would you know whether there's a way to install a specific version of MySQL 5.6 like 5.6.35? – bphilipnyc Jan 4 '17 at 4:03
up vote 9 down vote accepted

Looks that I managed to do it.

  1. In Software & Updates/Other Software added 14.04 repository:

    deb http://archive.ubuntu.com/ubuntu trusty main
    
  2. Installed mysql client and server:

    sudo apt install mysql-server-5.6
    sudo apt install mysql-client-5.6
    

Update: Before installing 5.6, make sure that no other mysql packages are present:

dpkg -l | grep mysql - returns list of mysql packages.

Use apt-get purge <package name> to purge them.

Source: 16.04 upgrade broke mysql-server

  • 1
    Good solution, but why do you need 5.6 instead of 5.7? – Uwe Burger Apr 25 '16 at 18:43
  • 5
    5.7 is not backward compatible. Some SQLs of application I'm working on fail... – Tarlog Apr 25 '16 at 18:48
  • 2
    What error are you getting? I suspect that it is due to the ONLY_FULL_GROUP_BY flag which is "on" by default in MySQL 5.7. Set it to off and you may be fine. – Jaydee Jun 15 '16 at 10:35
  • Currently I don't remember the details, I tried it almost two months ago. If I remember correctly, it was about some dates processing. Maybe parsing of dates. – Tarlog Jun 15 '16 at 10:50
  • 5.7 actually enforces table schema – Richard Haven Jun 22 '16 at 20:03

I was facing same issue and I have performed simple steps below:

 sudo apt-get install software-properties-common
 $ sudo add-apt-repository -y ppa:ondrej/mysql-5.6
 $ sudo apt-get update
 $ sudo apt-get install mysql-server-5.6

Solution worked for me Cheers!!

  • In addition to this solutions: You must remove these folders first: /etc/mysql/ /var/lib/mysql /var/log/mysql /var/lib/mysql-filters /var/lib/mysql-keyring And this file: /var/lib/mysql/debian-5.7.flag – user438136 Jul 22 '17 at 12:41
  • 3
    To quote ondrej: "don't use, broken". Check out here launchpad.net/~ondrej – Fractalf Sep 1 '17 at 11:55
dpkg --force-depends -P `dpkg -l |awk '/mysql/{print $2}'`

rm -r /etc/mysql/

apt-get install mysql-server mysql-client

The MySQL developers provide Xenial packages of MySQL 5.6 in their own repositories, and this should thus be preferred over installing the official Ubuntu Trusty packages, since it is in general better to install packages which were created for your version of Ubuntu.

If you already have MySQL Server packages, you should first uninstall them; just uninstall everything that is shown by dpkg -l | grep mysql-server.

Just download and install the mysql-apt-config DEB package in the previous link. During the installation, it will ask which version you want, so you can choose 5.6. After the package is done installing, sudo apt update && sudo apt install mysql-server-5.6 will install MySQL Server 5.6.

  • 3
    This doesn't work, there is no 5.6 version option, only 5.7 – Frodik Aug 4 '17 at 7:11
  • 5
    Indeed it seems that since this answer was written, MySQL 5.6 support was removed from the mysql-apt-config package, which is weird because it is still listed as supported on the linked page... – fkraiem Dec 23 '17 at 3:51

I had the same problem, and I tried a lot of options. And I had a lot of problems with libdbd-mysql-perl; the system said that was not going to install that library.

So I thought to install it with the Aptitude that install a package and correct all the dependencies.

If you don't have aptitude you can get it like this:sudo apt-get install aptitude

First all you need to uninstall your existing mysql. Next you need to install the package that you want.

sudo aptitude install mysql-server-5.6

The aptitude give you a lot of option, what to do. The first options is to keep the actual package. So press (N)o until you find the option that say to downgrade the next packages:

libmysqlclient20 [5.7.14-1ubuntu16.04 (<NULL>, now) -> 5.7.13-0ubuntu0.16
mysql-common [5.7.14-1ubuntu16.04 (<NULL>, now) -> 5.6.30-1+deb.sury.org

then press (Y)es and the aptitude is going to install the mysql-server-5.6. Here's the option that you should accept:

enter image description here

If after that the system cannot connect to mysql server you need to restart your computer.

protected by Community Jun 8 '17 at 10:34

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.