简体   繁体   中英

How can I install MySQL 5.7 on Ubuntu 22.04 LTS?

The company I am working uses an older stack, and I need to install MySQL 5.7 on my Ubuntu 22.04 LTS to work on some projects locally. Does anyone knows how to do this? I just can't find anything besides installing it on Ubuntu 20.04 or lower.

download:

wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
dpkg -i mysql-apt-config_0.8.12-1_all.deb

select this options:

Bionic -> MySQL Server and Cluster -> mysql-5.7 -> ok

add key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
apt-get update

check available mysql versions:

apt-cache policy mysql-server


mysql-server:
      Installed: (none)
      Candidate: 8.0.27-0ubuntu0.20.04.1
      Version table:
         8.0.27-0ubuntu0.20.04.1 500
            500 http://ru.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
            500 http://ru.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages
         8.0.19-0ubuntu5 500
            500 http://ru.archive.ubuntu.com/ubuntu focal/main amd64 Packages
         5.7.37-1ubuntu18.04 500
            500 http://repo.mysql.com/apt/ubuntu bionic/mysql-5.7 amd64 Packages

and install it:

apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*

Done

I have fixed this issue for me with a small trick.What we actually need to do is edit our /etc/apt/sources.list with the source.list available in Ubuntu 20.4. eg. you will get an entry in ubuntu 22 "deb http://in.archive.ubuntu.com/ubuntu/ jammy main restricted"

so just replace jammy by bionic in all places in /etc/apt/sources.list then save and try apt update after then just simply try to install myslq sudo apt install -fmysql-server=5.7* can use this command and now you can able to install mysql successfully.

Once you are installed and mysql is up and running just make sure to revert the /etc/apt/sources.list file.

Reason for doing this is in Ubuntu 22.04 it is not bale to install all required dependencies for mysql5.7 so by editing source.list we allow to install all req dependencies.

Note: Don't use upgrade in while doing this all and make sure you revert the source.list file after myslq installed and plz mark mysql on hold for upgrade because whenever you run an upgrade command it will upgrade the mysql version to 8 from 5.

Hope this work for you. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM