Back-porting MySQL 5.6 to Ubuntu 12.04 LTS

Sometimes you need something a little…non-standard. Like, for example, to run a new version of MySQL 5.6 on your slightly older Ubuntu 12.04 server. Ubuntu 12.04 doesn’t come with MySQL 5.6 out of the box, so you have a few options here:

  • Upgrade the OS
  • Use the .deb packages
  • Roll your own packages
  • Compile from source

A full blown OS upgrade is a bit of a nuclear option in a large environment. There’s testing, QA and a multitude of other dependencies to consider. The packages are next to useless unless you are a fan of wrapping them with something to drop a custom init script, create all the data/log directories and setup the appropriate users/groups. They also lack all the apt metadata which ties all the packaging together under Ubuntu. This means you’ll probably get your server running and then find something else has dragged in the 5.5 client libraries and left you with a bit of a mess.

What follows is a very simple version of the last two options above. Compile from source and package…..but, done the Ubuntu way.

Conveniently, Ubuntu 14.04 does ship with MySQL 5.6. So, we could just point at the Trusty Tahr apt repo and pull the binaries down but, since the binaries were built against 14.04, this also drags with it hundreds of dependencies including updated libc libraries. This leaves you with a mix-and-match install of 12.04 with portions of 14.04 overlayed on top. Your mileage, as they say, may vary! What we need is a quick way of building 5.6 against a 12.04 install.

Happily, after a bit of research, there is an easy ‘Ubuntu’ way. You will need a fairly well spec’d 12.04 build machine for the following and this should work for pretty much any package where you need to backport a newer version from a more recent Ubuntu.

First, we need to add the Trusty Tahr source repo to our apt sources.list and pull down the repo indexes.

echo deb-src mirror:// trusty main universe > /etc/apt/sources.list.d/mysql.list
apt-get update

Secondly, there are a few build dependencies to allow us to compile the source and build the packages.

apt-get install apt-build

And finally, a one-liner to actually pull down the source, compile and package it all up.

apt-build build-source mysql-server-5.6

This will drop off a series of .deb packages which will nicely install on any 12.04 machine. You can either drop these in your in-house apt repository or install them locally with a, for example:

dpkg -i mysql-server-5.6_5.6.16-1~exp1_amd64.deb