46

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?

Tarlog
  • 669

6 Answers6

75

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.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
basex
  • 866
  • 10
    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 07 '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 03 '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? – riddle_me_this Jan 04 '17 at 04:03
  • If mysql-server-5.6 is failing to start you may nee to unmask it with: systemctl unmask mysql.service – Matthew Buckett Jan 20 '17 at 15:26
  • The raw directions above worked for me, but in order to start the service and then schedule it to automatically load during boot, I had to issue sudo systemctl start mysql && sudo systemctl enable mysql – redgeoff Apr 27 '17 at 22:48
  • Also, there is a bug with this version of MySQL that leads to the my.cnf not being read due to it being a symlink. For details see http://stackoverflow.com/a/39454735/2831606 – redgeoff May 03 '17 at 20:57
  • If you get error add-apt-repository: command not found, then you would software-properties-common package as well which will be enough for Ubuntu 16.04 apt-get update && apt-get install software-properties-common – Abdul Mannan Mar 25 '18 at 15:37
10

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

Tarlog
  • 669
9

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!!

Ramesh Chand
  • 7,274
  • 4
  • 33
  • 37
  • 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 –  Jul 22 '17 at 12:41
  • 3
    To quote ondrej: "don't use, broken". Check out here https://launchpad.net/~ondrej – Fractalf Sep 01 '17 at 11:55
3
dpkg --force-depends -P `dpkg -l |awk '/mysql/{print $2}'`

rm -r /etc/mysql/

apt-get install mysql-server mysql-client
amc
  • 7,142
1

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.

Zanna
  • 70,465
rebduvid
  • 111
1

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.

fkraiem
  • 12,555
  • 4
  • 35
  • 40
  • 3
    This doesn't work, there is no 5.6 version option, only 5.7 – Frodik Aug 04 '17 at 07: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 03:51