7

Is it possible to install MySQL Server 5.7 on Ubuntu 19.10? If yes, how?

0

3 Answers 3

14

MySQL server 5.7 isn't available in the repositories of Eoan Ermine (19.10) but is available in Bionic Beaver (18.04) from Ubuntu's official repostories as well as MySQL's. You can install MySQL Server 5.7 on Eoan using Bionic's repository.

  1. To use MySQL's repository for Ubuntu 18.04

    • First of all create a new text file with sudo privileges:

      sudo nano /etc/apt/sources.list.d/mysql.list
      
    • Add these lines:

      deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config
      deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7
      deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools
      #deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools-preview
      deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7
      

      You can comment/uncomment the repository according to the packages required. Save and exit using Ctrl+X followed by Y. Then run

      sudo apt update
      
    • You'll get an error, like

      Err:1 http://repo.mysql.com/apt/ubuntu bionic InRelease                        
        The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <some key value>
      
    • Add this key using

      sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <key value>
      
    • Update and check which version of MySQL 5.7 is currently available

      sudo apt update
      apt-cache policy mysql-server
      

      At the time of writing this answer, 5.7.29-1ubuntu18.04 was available.

    • Install the required MySQL version.

      sudo apt install mysql-server=5.7.29-1ubuntu18.04
      

    Note: For some reasons in my installation APT wasn't installing mysql-client while installing MySQL Server 5.7 which is a dependency of MySQL Community Server which in turn is a dependency of MySQL Server due to which dependency issues occured. To get out of that I needed to install MySQL client using APT first

    sudo apt install mysql-client=5.7.29-1ubuntu18.04
    
  2. To install using Ubuntu's repositories, add Ubuntu 18.04's official repositories, update the cache and instal MySQL 5.7. Fo that run:

    echo "deb http://security.ubuntu.com/ubuntu/ bionic-security restricted main" | sudo tee /etc/apt/sources.list.d/bionic.list
    sudo apt update
    apt-cache policy mysql-server
    sudo apt install mysql-server=5.7.29-0ubuntu0.18.04.1
    

    I'd recommend to delete Bionic's repository after the installation since having repository information of other releases can sometime break the installation. To do that run

    sudo rm /etc/apt/sources.list.d/bionic.list
    
10
  • 1
    at present the mysql version on that repository is: 5.7.29-1ubuntu18.04
    – epineda
    Jan 28, 2020 at 4:58
  • The second method leaves the user with no way to get security updates, right?
    – sarnold
    Feb 19, 2020 at 19:09
  • @sarnold Not really. Since in second method, MySQL was actually installed using Bionic's security packages sources. Addition of software sources of some other release can cause conflict of packages that are also in the current release. Here, only those sources were removed which were added solely for the purpose of installing MySQL to avoid future conflicts. You'll still get security updates from Eoan's repository.
    – Kulfy
    Feb 20, 2020 at 3:53
  • @Kulfy, I'm sorry, I should have been more clear -- your second method will leave the user with no way to receive mysql security updates, correct? There's no mysql-5.7 source package for eoan: launchpad.net/ubuntu/+source/mysql-5.7
    – sarnold
    Feb 21, 2020 at 19:57
  • @sarnold True that.
    – Kulfy
    Feb 22, 2020 at 4:12
4

Adding onto Kulfy's answer. If you want to prevent the package from being updated back to MySQL 8+, create a file named mysql at /etc/apt/preferences.d/.

In that file place the following contents

Package: mysql-server
Pin: version 5.7.29-1ubuntu18.04
Pin-Priority: 1001

Package: mysql-client
Pin: version 5.7.29-1ubuntu18.04
Pin-Priority: 1001

Package: mysql-community-server
Pin: version 5.7.29-1ubuntu18.04
Pin-Priority: 1001

Package: mysql-community-client
Pin: version 5.7.29-1ubuntu18.04
Pin-Priority: 1001

This will prevent apt upgrade from upgrading MySQL back to version 8.

NOTE: The version you use may be different, as of 2/12/2020 the version is 5.7.29-1ubuntu18.04. To get the version run apt list --installed | grep -E 'mysql-(client|server)'.

2

Extending on the answers of both Kulfy and NSwanson7, the installation can be fixed to version 5.7.*. No need to specify an exact version.

  1. Pin the version of mysql-client and mysql-server to 5.7*. For this create the file /etc/apt/preferences.d/mysql with content
    Package: mysql-server
    Pin: version 5.7*
    Pin-Priority: 1001
    
    Package: mysql-client
    Pin: version 5.7*
    Pin-Priority: 1001
    
  2. Add repositories from Ubuntu 18.04. For this create file /etc/apt/sources.list.d/mysql.list with content
    deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config
    deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7
    deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools
    deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7
    
  3. Update repos and install
    sudo apt update && sudo apt install mysql-client mysql-server
    

or use the below script:

echo "deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config"  | sudo tee /etc/apt/sources.list.d/mysql.list
echo "deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7"  | sudo tee -a /etc/apt/sources.list.d/mysql.list
echo "deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools"  | sudo tee -a /etc/apt/sources.list.d/mysql.list
echo "deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7"  | sudo tee -a /etc/apt/sources.list.d/mysql.list

echo "Package: mysql-server" | sudo tee /etc/apt/preferences.d/mysql
echo "Pin: version 5.7*" | sudo tee -a /etc/apt/preferences.d/mysql
echo "Pin-Priority: 1001" | sudo tee -a /etc/apt/preferences.d/mysql
echo "" | sudo tee -a /etc/apt/preferences.d/mysql
echo "Package: mysql-client" | sudo tee -a /etc/apt/preferences.d/mysql
echo "Pin: version 5.7*" | sudo tee -a /etc/apt/preferences.d/mysql
echo "Pin-Priority: 1001" | sudo tee -a /etc/apt/preferences.d/mysql

sudo apt update
sudo apt -y install mysql-server mysql-client

You must log in to answer this question.

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