共计 2269 个字符,预计需要花费 6 分钟才能阅读完成。
背景介绍
ubuntu 20.04 版本零碎自带的 MySQL 版本是 8.0,一般办法很难装置 5.7 版本的。因为 8.0 版本较 5.7 版本做了不少改变,笔者比拟习惯应用 5.7 版本。
网上搜做了一圈,跟着各种教程试了很多遍,最初终于找到了胜利的办法。过程记录分享进去,供大家参考。
装置过程
笔者的环境:
[email protected]:/home# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"
- 若曾经装置了 8.0 版本的 MySQL,请先操作删除。
-
增加 MySQL 源
sudo vim /etc/apt/sources.list.d/mysql.list
增加如下内容,
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
更新,
sudo apt update
执行过程中可能会呈现如下谬误,
W: GPG error: http://repo.mysql.com/apt/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29 E: The repository 'http://repo.mysql.com/apt/ubuntu bionic InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
执行如下命令即可,
467B942D3A79BD29
依据理论状况替换。[email protected]:/home# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
接着再从新执行更新,
sudo apt update
- 装置 MySQL
查看反对的 MySQL 版本,此处咱们曾经能够看到有 5.7.40-1ubuntu18.04
,靠近胜利了。
[email protected]:/home# sudo apt-cache policy mysql-server
mysql-server:
Installed: (none)
Candidate: 8.0.30-0ubuntu0.20.04.2
Version table:
8.0.30-0ubuntu0.20.04.2 500
500 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages
500 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages
8.0.19-0ubuntu5 500
500 http://mirrors.aliyun.com/ubuntu focal/main amd64 Packages
5.7.40-1ubuntu18.04 500
500 http://repo.mysql.com/apt/ubuntu bionic/mysql-5.7 amd64 Packages
装置 MySQL 5.7 版本客户端和服务端,版本信息依据下面的输入自行批改。
sudo apt install mysql-server=5.7.40-1ubuntu18.04
sudo apt install mysql-client=5.7.40-1ubuntu18.04
如无需装置 mysql-client 服务,执行装置 mysql-server 服务,可能会报如下谬误。
只须要手动装置 mysql-community-server 即可。sudo apt install mysql-community-server=5.7.40-1ubuntu18.04
The following packages have unmet dependencies:
mysql-server : Depends: mysql-community-server (= 5.7.40-1ubuntu18.04) but it is not going to be installed
-
验证
[email protected]:/home# mysql --version mysql Ver 14.14 Distrib 5.7.40, for Linux (x86_64) using EditLine wrapper
ok,完结。踩坑君再次填好一个坑,接着去踩下一个啦。
参考:
- Is it possible to install MySQL Server 5.7 on Ubuntu 19.10?
- Install MySQL 5.7 on Ubuntu 20.04
正文完
发表至: ubuntu20.04
2022-10-24