Unable to install mysql 5.7 on ubuntu 20.04

21,062

Solution 1

Mysql 5.7 is not available to the Ubuntu 20.04. Only mysql 8.0 and higher version are available to Ubuntu 20.04 when you use mysql repository. Here you are using bionic source list (Ubuntu 18.04) for Ubuntu 20.04. I believe this workaround sometimes causes messup with dependencies tree.

You need to download mysql 5.7 packages with their dependencies from official mysql site here and install manually by executing below command in terminal.

sudo dpkg -i <package name>

Solution 2

The later error mysql-community-server : Depends: mysql-client (= 5.7.31-1ubuntu18.04) but 8.0.20-0ubuntu0.20.04.1 is to be installed is occurred because of multiple versions of MySQL available. When you tried to install mysql-community-server 5.7, APT tried to fetch latest mysql-client which is 8.0 since all have same priority and that's incompatible with MySQL 5.7.

Though installing packages one by one using DPKG as mentioned by other answer is fine but that may be long manual task.

To make APT fetch mysql-client 5.7, consider changing priorities. To do that run

sudoedit /etc/apt/preferences.d/mysql

and add

Package: mysql-server
Pin: version 5.7*
Pin-Priority: 1001

Package: mysql-client
Pin: version 5.7*
Pin-Priority: 1001

Retry installation process. sudo apt install mysql-server should now fetch 5.7 by default.

Solution 3

This:

sudo apt install -f mysql-client=5.7.30-1ubuntu18.04

should be:

sudo apt install -f mysql-client=5.7.31-1ubuntu18.04

I landed on your question with the same problem and solved this by looking here http://repo.mysql.com/apt/ubuntu/dists/bionic/mysql-5.7/binary-amd64/Packages

Share:
21,062
Maaz Anzar
Author by

Maaz Anzar

Updated on September 18, 2022

Comments

  • Maaz Anzar
    Maaz Anzar almost 2 years

    Can anyone help me in installing mysql 5.7. I tried following this answer, but when I run

    sudo apt-cache policy mysql-server
    

    It gives me:

    8.0.20-0ubuntu0.20.04.1 500
        500 http://pk.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://pk.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
    8.0.19-0ubuntu5 500
        500 http://pk.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://pk.archive.ubuntu.com/ubuntu focal/main i386 Packages
    5.7.31-1ubuntu18.04 500
        500 http://repo.mysql.com/apt/ubuntu bionic/mysql-5.7 amd64 Packages
    5.7.30-0ubuntu0.18.04.1 500
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages
    

    Which are different from the linked answer.

    When I tried to

    sudo apt install -f mysql-client=5.7.30-1ubuntu18.04
    

    It gives me error

    Version '5.7.30-1ubuntu18.04' for 'mysql-client' was not found.
    

    When I run sudo apt install -f mysql-client-5.7 command it installed mysql version. I also does not finds mysql-community-server=5.7.30-1ubuntu18.04.

    I tried to run sudo apt install -f mysql-community-server It gives me following error:

    mysql-community-server : Depends: mysql-client (= 5.7.31-1ubuntu18.04) but 8.0.20-0ubuntu0.20.04.1 is to be installed
    
  • Maaz Anzar
    Maaz Anzar almost 4 years
    When tried to run ``` sudo dpkg -i mysql-community-server_5.7.31-1ubuntu18.04_i386.deb ``` mysql-community-server:i386 : Depends: perl:i386 but it is not installed
  • Kulfy
    Kulfy almost 4 years
    @MaazAnzar You don't have to install 32 bit packages as well if you're having 64 bit OS.
  • Maaz Anzar
    Maaz Anzar almost 4 years
    Thanks It worked!! I first installed related Libraries and than install mysql
  • Serg
    Serg over 3 years
    This works well. The link in the answer works and shows .33 at the moment I've checked it.
  • Taffarel Xavier
    Taffarel Xavier almost 3 years
    Perfect! Thanks! All work for me.
  • GDP2
    GDP2 over 2 years
    In case others have similar trouble: I downloaded the entire DEB Bundle package on that link. Then, I extracted the tarball into its own folder. Once inside the folder, I ran sudo dpkg -i *.deb. Halfway through the installation process, it failed on mysql-community-client. Apparently certain dependencies were unmet. In order to fix this, I had to run sudo apt-get install --fix-broken. Then, I was able to re-run sudo dpkg -i *.deb and it finished successfully. The Oracle docs were also useful to me: docs.oracle.com/cd/E17952_01/mysql-5.6-en/…