8

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
ahmedg
  • 267

4 Answers4

7

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.

yfluK
  • 291
6

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>
KK Patel
  • 19,753
4

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

ahmedg
  • 267
David
  • 41
1

Nothing here quite worked for me, perhaps because I was installing in a Dockerfile. Here's what did work

sed -i -e 's|focal|bionic|g' /etc/apt/sources.list
apt-get -qq update
apt-get install --no-install-recommends -y mysql-client-5.7

Either do that last thing, or you could always set your sources.list back to focal with

sed -i -e 's|bionic|focal|g' /etc/apt/sources.list
mmrobins
  • 111