14

I recently upgraded to Ubuntu 16.04. Unfortunately I need to work MySQL 5.5 or 5.6. I tried many solutions to have MySQL 5.5 or 5.6 run on Ubuntu 16.04 like this Install MySql 5.6 on Ubuntu 16.04 . But none of them is working. Ubuntu detect the unmet dependencies but says "but it is not going to be installed" for 5.5 or says Package 'mysql-server-5.6' has no installation candidate...

Is it not possible to force an earlier version of MySQL on Ubuntu? Why is that?

4
  • 1
    The official Ubuntu 16.04 repositories do not contain any version of MySQL other than 5.7. If you want another version, you have to find package from another source. You should really not have upgraded to 16.04 without checking this.
    – fkraiem
    Apr 26, 2016 at 16:22
  • 2
    Possible duplicate of How to install MySQL 5.6? Apr 26, 2016 at 20:49
  • Which of the answer(s) of the linked question did you try? Some use the Deb package from Oracle or even compile it from source which should work no matter the state of the software repository. Apr 26, 2016 at 20:50
  • @fkraiem "You should really have no upgraded ... without checking this" - you're presuming the necessity of MySQL 5.5 was known at the time of upgrading. I recently started a new job with old software which requires MySQL 5.5 (nothing newer) - so I should have checked all possible employers and what they are running before upgrading? Mar 5, 2018 at 17:50

4 Answers 4

25

Step by step guide* to install mysql 5.5.x on Ubuntu 16.04 Xenial-Xerus. Please see this documentation

OR

See steps below:

Installing MySQL 5.5.51 on Ubuntu 16.06

  1. Uninstall any existing version of MySQL

    sudo rm /var/lib/mysql/ -R
    
  2. Delete the MySQL profile

    sudo rm /etc/mysql/ -R
    
  3. Automatically uninstall mysql

    sudo apt-get autoremove mysql* --purge
    sudo apt-get remove apparmor
    
  4. Download version 5.5.51 from MySQL site

    wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
    
  5. Add mysql user group

    sudo groupadd mysql
    
  6. Add mysql (not the current user) to mysql user group

    sudo useradd -g  mysql mysql
    
  7. Extract mysql-5.5.51-linux2.6-x86_64.tar.gz to /usr/local

    cd /usr/local
    sudo tar -xvf mysql-5.5.49-linux2.6-x86_64.tar.gz
    
  8. Create mysql folder in /usr/local

    sudo mv mysql-5.5.49-linux2.6-x86_64 mysql
    
  9. Set mysql directory owner and user group

    cd mysql
    sudo chown -R mysql:mysql *
    
  10. Install the required lib package

    sudo apt-get install libaio1
    
  11. Execute mysql installation script

    sudo scripts/mysql_install_db --user=mysql
    
  12. Set mysql directory owner from outside the mysql directory

    sudo chown -R root .
    
  13. Set data directory owner from inside mysql directory

    sudo chown -R mysql data
    
  14. Copy the mysql configuration file

    sudo cp support-files/my-medium.cnf /etc/my.cnf 
    
  15. Start mysql

    sudo bin/mysqld_safe --user=mysql &
    sudo cp support-files/mysql.server /etc/init.d/mysql.server
    
  16. Initialize root user password

    sudo bin/mysqladmin -u root password '111111'
    
  17. Start mysql server

    sudo /etc/init.d/mysql.server start
    
  18. Stop mysql server

    sudo /etc/init.d/mysql.server stop
    
  19. Check status of mysql

    sudo /etc/init.d/mysql.server status
    
  20. Enable myql on startup

    sudo update-rc.d -f mysql.server defaults 
    
  21. Disable mysql on startup (Optional)

    sudo update-rc.d -f mysql.server remove
    
  22. Add mysql path to the system

    sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
    
  23. Now directly use the command below to start mysql

    mysql -u root -p 
    

PS: One needs to reboot in order for the changes to take place.

Based on a Chinese blog

9
  • 1
    Works like a sharm! Thank you. Only one thing - if you install MySQL on Ubuntu 16 - do not create systemctl script - after rebooting it will create by itself automatically.
    – 1nstinct
    Oct 7, 2016 at 13:38
  • 2
    The reboot needs to occur between steps #16 and #17 for steps #17-21 to work.
    – e_i_pi
    Jun 5, 2017 at 4:10
  • did all this but ended up with dependency problems (presumably some shared libraries got into a wrong version). Nov 5, 2017 at 20:02
  • Is it really necessary to remove apparmor? I'm not seeing a line to reinstall afterwards. I don't know too about apparmor but it seems like uninstalling it is a security issue.
    – pmagunia
    Nov 12, 2017 at 22:20
  • 1
    Works perfectly, thank you ! +1
    – Liso
    Mar 31, 2020 at 10:42
4

Try this, First you have to remove

sudo rm /var/lib/mysql/debian-5.7.flag

then

sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
sudo apt-get update
sudo apt install mysql-server-5.6
sudo apt install mysql-client-5.6
2

This answer helped me figure out how to do it by downloading the .deb packages from MySQL dev site. The solution about adding the PPA did not do it for me.

It links to a blogpost: How to Install MySQL-5-6 on Ubuntu Precise Tricky but it works.

2

A simpler alternative is to use Percona Server. By their documentation:

Installing Percona Server from Percona apt repository

  1. Fetch the repository packages from Percona web:

    wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
    
  2. Install the downloaded package with dpkg. To do that, run the following commands as root or with sudo:

    dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
    

    Once you install this package the Percona repositories should be added. You can check the repository setup in the /etc/apt/sources.list.d/percona-release.list file.

  3. Remember to update the local cache:

    apt-get update
    
  4. After that you can install the server package:

    apt-get install percona-server-server-5.5
    
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.