13

I'm finding MySQL 5.7 to be a massive memory hog and want to roll back to MySQL 5.6.

However everytime I try to uninstall 5.7 and install 5.6 I end up with a MySQL service that won't start. Also I need to make sure I keep all of my databases.

Can anyone tell me a simple step by step on how to roll back mysql from 5.7 to 5.6?

**UPDATE**
$ dpkg -l | grep mysql    

rc  akonadi-backend-mysql                                1.13.0-2ubuntu4                                      all          MySQL storage backend for Akonadi  
ii  dbconfig-mysql                                       2.0.4ubuntu1                                         all          dbconfig-common MySQL/MariaDB support  
ii  libdbd-mysql-perl                                    4.033-1build2                                        amd64        Perl5 database interface to the MySQL database  
rc  libmysqlclient18:amd64                               5.6.30-0ubuntu0.15.10.1                              amd64        MySQL database client library  
rc  libmysqlclient18:i386                                5.6.30-0ubuntu0.15.10.1                              i386         MySQL database client library  
ii  libmysqlclient20:amd64                               5.7.12-0ubuntu1.1                                    amd64        MySQL database client library  
ii  mysql-client-5.7                                     5.7.12-0ubuntu1.1                                    amd64        MySQL database client binaries  
ii  mysql-client-core-5.7                                5.7.12-0ubuntu1.1                                    amd64        MySQL database core client binaries  
ii  mysql-common                                         5.7.12-0ubuntu1.1                                    all          MySQL database common files, e.g. /etc/mysql/my.cnf  
iU  mysql-server                                         5.7.12-0ubuntu1.1                                    all          MySQL database server (metapackage depending on the latest version)  
rc  mysql-server-5.5                                     5.5.43-0ubuntu0.14.10.1                              amd64        MySQL database server binaries and system database setup  
rc  mysql-server-5.6                                     5.6.16-1~exp1                                        amd64        MySQL database server binaries and system database setup  
iF  mysql-server-5.7                                     5.7.12-0ubuntu1.1                                    amd64        MySQL database server binaries and system database setup  
ii  mysql-server-core-5.7                                5.7.12-0ubuntu1.1                                    amd64        MySQL database server binaries  
ii  php-mysql                                            1:7.0+42+deb.sury.org~xenial+2                       all          MySQL module for PHP [default]  
ii  php5.6-mysql                                         5.6.23-1+deb.sury.org~xenial+2                       amd64        MySQL module for PHP  
ii  php7.0-mysql                                         7.0.8-2+deb.sury.org~xenial+1                        amd64        MySQL module for PHP  
7
  • The official Ubuntu 16.04 repositories only have 5.7, so first you will need to find a repository which provides 5.6. Maybe the official MySQL one.
    – fkraiem
    Commented Jun 29, 2016 at 3:21
  • I've already added the trusty repo to access MySQL 5.6
    – dibs
    Commented Jun 29, 2016 at 3:37
  • You shouldn't do that, especially since it seems there are 5.6 packages for Xenial.
    – fkraiem
    Commented Jun 29, 2016 at 3:38
  • For example, the system to manage services has changed (Trusty uses upstart, Xenial uses systemd), so it is not surprising that a service in a package made for Trusty (with upstart) does not start in Xenial (with systemd).
    – fkraiem
    Commented Jun 29, 2016 at 3:40
  • Ah wow. Maybe this is why no matter what I have tried seems to work.
    – dibs
    Commented Jun 29, 2016 at 3:41

2 Answers 2

7

First make a mysqldump of all your databases (including information_schema). Then "stop" mysql" and this will remove anything related to mysql:

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7

# Backup 5.6 config and data without deleting
sudo mv /etc/mysql /etc/mysql-5.6-backup
sudo mv /var/lib/mysql /var/lib/mysql-5.6-backup
sudo apt-get autoremove
sudo apt-get autoclean

and then

sudo apt-get install mysql-client-5.6
sudo apt-get update

Warnings:

  • Ubuntu switched to systemd with 16.04. You may need to start 16.04 with upstart too when using mysql 5.6.
8
  • 1
    I'm pretty sure that $ sudo rm -rf on /var/lib/mysql will blow away all of my databases.
    – dibs
    Commented Jun 29, 2016 at 3:39
  • It will but you can not keep /var/lib/mysql/ anyways. You need a dump of your database so you can reload it. Otherwise you'd pick up settings from 5.7 than are invalid in 5.6
    – Rinzwind
    Commented Jun 29, 2016 at 6:40
  • 1
    I see another mistake: mysql needs to be stopped before you remove it. And another warning: we switched to systemd between 5.6 and 5.7. Not a dealbreaker but worth mentioning
    – Rinzwind
    Commented Jun 29, 2016 at 6:42
  • @Rinzwind what does this practically mean re: the systemd change? Also good to know I HAVE to dump dbs. I'll make sure I do that first.
    – dibs
    Commented Jun 30, 2016 at 2:26
  • 3
    mysql-client-5.6 is no longer available in apt-get by default. See askubuntu.com/questions/762384/… for how to install it.
    – Tony
    Commented Sep 28, 2016 at 20:07
0

I added the Ubuntu 14.04 repository (in Ubuntu 18.04):

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'

I am able to install:

sudo apt install mysql-client-5.6
2
  • 2
    This is a really bad idea. See askubuntu.com/questions/499800/….
    – fosslinux
    Commented May 24, 2018 at 22:40
  • Ok to do this, but don't update, and follow with "-r" remove once installe d"sudo add-apt-repository -r 'deb archive.ubuntu.com/ubuntu trusty universe'"as much as it is a bad idea to leave this in your repo, if you remove it once 5.6 is installed, I don't think this is as bad an idea as the above comment made. The same answer here has 60 upvotes, and he did an apt-get update, which has more potential to cause problems askubuntu.com/questions/762384/…
    – MagicLAMP
    Commented Sep 13, 2018 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .