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
  • 247

4 Answers4

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,083
  • 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 – Maaz Anzar Jul 21 '20 at 09:28
  • @MaazAnzar You don't have to install 32 bit packages as well if you're having 64 bit OS. – Kulfy Jul 21 '20 at 12:22
  • Thanks It worked!! I first installed related Libraries and than install mysql – Maaz Anzar Jul 24 '20 at 15:47
  • 1
    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: https://docs.oracle.com/cd/E17952_01/mysql-5.6-en/linux-installation-debian.html – GDP2 Feb 01 '22 at 07:18
6

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
  • 271
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
  • 247
David
  • 41
  • This works well. The link in the answer works and shows .33 at the moment I've checked it. – Serg Mar 21 '21 at 14:35
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
  • This one worked fine with one note: had to install Perl in addition to mysql-server-5.7. – AlexV Apr 03 '23 at 19:29