MySQL Blog Archive
For the latest blogs go to blogs.oracle.com/mysql
Upgrading to MySQL 5.7 Using the MySQL Repos for Linux

MySQL Server 5.7 was released around a month ago, and download numbers show huge interest in upgrading from older MySQL releases. As with any product that is frequently used as core infrastructure in complex systems with numerous interdependencies, major version upgrades of MySQL should be approached with some care. In this post, I will cover an essential part of such an upgrade, namely the mechanics of using the MySQL repos to do the actual upgrade. I will focus on upgrades from 5.6 to 5.7, and given the large number of ways that users may have tweaked their repo setups, I will limit myself to discussing scenarios that should cover the vast majority of cases. But first some general words about the business of upgrading to a new MySQL major version.

We’re in general applying a principle of least surprise wherever we can in product design and behavior, and that very much directs what should happen when a new MySQL major version comes out and you have an older version of MySQL installed from our repos: an apt-get upgrade should absolutely not silently and suddenly do a major version upgrade. While we have gone to great lengths in both development and testing to make sure that major version upgrades are as uneventful as possible, a new version will always behave somewhat differently, so some care needs to be exercised when upgrading, in particular where MySQL is used as a component in a large and complex infrastructure.

In short: a major version upgrade has to be a conscious decision.

If you’re using the MySQL package repos for Linux, once you have analyzed what an upgrade will mean for your setup, especially the Before You Begin section, plus taken the highly recommended precaution of backing up your database, the likelihood is that upgrading from MySQL 5.6 to 5.7 is largely a matter of upgrading the repo setup package and selecting 5.7. We will go through a few of the scenarios that you may encounter, and I will start off by covering the Debian/Ubuntu Apt repos.

You Have MySQL 5.6 from the MySQL Apt Repo on Ubuntu/Debian

I will assume that you originally installed the repo setup package from the Apt repo web page. See the note below if you chose the somewhat less recommended route of manually adding the MySQL repo to your system. Also note that the procedure discussed holds for those who have been using MySQL 5.7 pre-release versions, so called Development Milestone Releases.

The first step is always to make sure that you have the latest version both of the MySQL repo setup package and of MySQL 5.6 itself. Run apt-get update, then apt-get upgrade. If upgrades are offered for mysql-apt-config or for any of the MySQL Server bits (mysql-*), choose to upgrade them.

Depending on the initial update state of your system, the apt-get upgrade process may prompt you for the version of MySQL you want. Select 5.7. If you do not get this prompt, force a reconfiguration by using the command dpkg-reconfigure mysql-apt-config, then select 5.7.

You should now have a repo setup that has 5.7 selected as the desired MySQL version, and your system is ready for upgrade. Again, run apt-get update, then apt-get upgrade. You should now see another batch of MySQL Server package upgrades being offered. Accept the upgrades and you should soon have a running MySQL 5.7 install on your system.

And finally you need to run the mysql_upgrade command so that data and system internal structures get transformed to the MySQL 5.7 format.

NOTE: If you didn’t originally download the repo setup package and instead opted for manually editing the repo setup on your system, we recommend that you download and install the Apt repo setup package. Alternatively, you will have to manually edit your system’s repo setup again in order to enable 5.7.

You Have MySQL 5.6 from the MySQL Yum Repo on Enterprise Linux/Fedora

Again, I am assuming that you originally set up the MySQL repo on your system by using the repo setup package from the Yum repo web page.

To upgrade from 5.6 to 5.7 on a Yum-based system you will need to edit the /etc/yum.repos.d/mysql-community.repo MySQL repo setup file on your system to specify 5.7 as the desired version. Open the file for editing and locate the [mysql56-community] section. Change the “enabled” setting in that section to 0, then locate the [mysql57-community] and change the “enabled” setting to 1.

Then proceed to carry out the upgrade:

yum update mysql-community-server

… or if you’re using dnf:

dnf --refresh upgrade mysql-community-server

Your system now has MySQL 5.7 installed and running.

Finally, run the mysql_upgrade command to automatically transform data and system internal structures to the format used by MySQL 5.7.

Other Scenarios

Your system may conceivably be in a state where the procedures above won’t work “out of the box”, but we have hopefully covered the vast majority of cases. If you need more information, I strongly recommend consulting the MySQL Reference Manual, specifically the Upgrading MySQL section.

Another type of scenario is on systems where you want to upgrade to 5.7 from versions older than 5.6. The supported procedure for that is to upgrade via each intermediate version, so e.g. moving from 5.5 is a two step process: first follow the relevant procedure for your system above to upgrade to 5.6, then repeat that procedure to go from 5.6 to 5.7. To go to 5.7 from even older versions, please refer to the upgrade section of the reference manual.

Final Notes

We have gone through the most common scenarios for upgrading to MySQL 5.7 using the MySQL repos for Linux. For future versions of MySQL we will aim to improve the robustness of the repo setup package so that we can handle more scenarios with less manual intervention. That is of course subject to the limitations of the Apt and Yum/Dnf package managers, but some improvements are definitely possible.

If this posting whetted your appetite for 5.7, there is a lot more information available about the release at the MySQL Server blog, and for those who prefer a shorter summary, we have a terse list of new features over at http://www.thecompletelistoffeatures.com/.

In the meantime, if you encounter issues with upgrading that you think are related to the way our repos and packages work, please file a bug report at http://bugs.mysql.com under the category “MySQL Package Repos and Docker Images”.