Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Downgrade mysql to mysql 5.6 on xenial

Install MySQL 5.6 in Ubuntu 16.04

Ubuntu 16.04 only provides packages for MySQL 5.7 which has a range of backwards compatibility issues with code written against older MySQL versions.

Oracle maintains a list of official APT repositories for MySQL 5.6, but those repositories do not yet support Ubuntu 16.04. However, the 15.10 repos will work for 16.04.

Uninstall existing mysql 5.7 if any

sudo apt remove mysql-client mysql-server libmysqlclient-dev mysql-common

Check you removed everything

sudo dpkg -l | grep mysql

Purge remainders (e.g. marked with rc) with

sudo dpkg -P <package> [<package> ...].

Download the apt_config-debian package from Oracle and install it using from https://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.0-1_all.deb

Choose "MySQL 5.6" and "Ubuntu Wily" (assuming Xenial is not yet provided) Community reports, that for Ubuntu 17.10, 18.04 you should select "Ubuntu Trusty"

Add repository to unsupported system? 
select - ubuntu trusty

Run

sudo apt-cache policy mysql-server  

If this shows a 5.6 version, continue.

If not, check your /etc/apt/sources.list.d/mysql.list. It should look roughly like this:

### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/ubuntu/ wily mysql-apt-config
deb http://repo.mysql.com/apt/ubuntu/ wily mysql-5.6
deb http://repo.mysql.com/apt//ubuntu/ wily mysql-tools
deb-src http://repo.mysql.com/apt/ubuntu/ wily mysql-5.6
You might have to replace "xenial" with "wily". Although you are using 16.04 (codename Xenial), Oracle currently seems to only provide 5.6 in the repos for 14.04 (codename Wiley). But those sources work for 16.04, too.

Create a file /etc/apt/preferences.d/mysql with this content

Package: *
Pin: origin "repo.mysql.com"
Pin-Priority: 999

Run

sudo apt-get update

Now recipe's run should provide

sudo apt install mysql-client mysql-server libmysqlclient-dev

You should get 5.6 version now.

Related ansible role: https://github.com/softasap/sa-mysql56

@mapindu

This comment has been minimized.

Copy link

@mapindu mapindu commented May 9, 2017

Thanx a lot! :-)

@mahardianto

This comment has been minimized.

Copy link

@mahardianto mahardianto commented May 26, 2017

maybe you can change mysql.list from willy to trusty, because willy it's not supported anymore

@aviantorichad

This comment has been minimized.

Copy link

@aviantorichad aviantorichad commented Aug 17, 2017

try using trusty, work well, thanks a lot

@hanzo2001

This comment has been minimized.

Copy link

@hanzo2001 hanzo2001 commented Jan 31, 2018

This no longer worked for me for some reason. I managed to do it manually and documented it here https://unix.stackexchange.com/a/421044/251875, just in case.

@TharangaSri

This comment has been minimized.

Copy link

@TharangaSri TharangaSri commented Feb 26, 2018

With Ubuntu 17.10 please use "ubuntu trusty",

Add repository to unsupported system? select - ubuntu trusty -

Now it work well, Thanks

@Tushar-Hawaldar

This comment has been minimized.

Copy link

@Tushar-Hawaldar Tushar-Hawaldar commented Apr 17, 2018

Should we revert back to xenial once done with installation?

@gabrielizaias

This comment has been minimized.

Copy link

@gabrielizaias gabrielizaias commented Aug 8, 2018

Worked on Ubuntu 18.04 as well, had to use trusty instead of wily.

@apippin

This comment has been minimized.

Copy link

@apippin apippin commented Aug 18, 2018

This worked great on Ubuntu 18.04 for me too, with the trusty change suggested. Thanks!

@sanjok-bless

This comment has been minimized.

Copy link

@sanjok-bless sanjok-bless commented Oct 26, 2018

On Ubuntu 16.04 had to use trusty, thanks!

@vsokolov

This comment has been minimized.

Copy link

@vsokolov vsokolov commented Jan 7, 2019

Thanks for gist.

Got a problem on purge step. ubuntu 18.04.1

After removing packages result of sudo dpkg -l | grep mysql is

rc mysql-apt-config 0.8.0-1 all Auto configuration for MySQL APT Repo.
ii mysql-client-core-5.7 5.7.24-0ubuntu0.18.04.1 amd64 MySQL database core client binaries
rc mysql-server-5.7 5.7.24-0ubuntu0.18.04.1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.7 5.7.24-0ubuntu0.18.04.1 amd64 MySQL database server binaries

e.g, trying sudo dpkg --purge mysql-client

dpkg: warning: ignoring request to remove mysql-client which isn't installed

@msnambiar

This comment has been minimized.

Copy link

@msnambiar msnambiar commented Apr 9, 2019

Hi, I am trying to install MySql 5.6 on Ubuntu 18.04 server. I have stuck below .. please advise how can I select ubuntu trusty

[admin@iicubuntu ~]# sudo dpkg -i mysql-apt-config_0.8.0-1_all.deb
Selecting previously unselected package mysql-apt-config.
(Reading database ... 234787 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.0-1_all.deb ...
Unpacking mysql-apt-config (0.8.0-1) ...
Setting up mysql-apt-config (0.8.0-1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
Configuring mysql-apt-config

The detected system (ubuntu bionic) is not supported by MySQL. If you believe
the platform is compatible with one of the supported systems, one of the
corresponding repositories may be selected.

  1. debian wheezy 3. ubuntu precise 5. ubuntu xenial
  2. debian jessie 4. ubuntu trusty 6. abort

Add repository to unsupported system?
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
Warning: The postinst maintainerscript of the package mysql-apt-config
Warning: seems to use apt-key (provided by apt) without depending on gnupg or gnupg2.
Warning: This will BREAK in the future and should be fixed by the package maintainer(s).
Note: Check first if apt-key functionality is needed at all - it probably isn't!
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK
Use of uninitialized value $val in substitution (s///) at /usr/share/perl5/Debconf/Format/822.pm line 83, line 6.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/perl5/Debconf/Format/822.pm line 84, line 6.
[admin@iicubuntu ~]#

@aqil-tariq-confiz

This comment has been minimized.

Copy link

@aqil-tariq-confiz aqil-tariq-confiz commented Apr 17, 2019

 mysql-server-5.6 : Depends: initscripts but it is not installable
                    Depends: mysql-client-5.6 (>= 5.6.16-1~exp1) but it is not going to be installed
                    Depends: sysv-rc (>= 2.88dsf-24) but it is not installable or
                             file-rc (>= 0.8.16) but it is not installable
E: Unable to correct problems, you have held broken packages.

I am getting this error. I have added https://dev.mysql.com/downloads/repo/apt/ and when I run sudo apt-get install mysql-server-5.6 then I get the above-mentioned error. I tried above debian too https://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb but it did not work.
Please help me I am stuck here since three days.

@aqil-tariq-confiz

This comment has been minimized.

Copy link

@aqil-tariq-confiz aqil-tariq-confiz commented Apr 17, 2019

@apippin @Voronenko @aviantorichad please help urgently. Have you got above mention issue

@Haco

This comment has been minimized.

Copy link

@Haco Haco commented May 27, 2019

Works perfectly on 16.04 with trusty. Thanks a bunch! Of course, you should dump your previous database before and re-import it later - this also works without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.