ubuntu20安装mysql5.7

通过以下命令查看系统默认的mysql-server版本:
apt-cache policy mysql-server

如果找不到,先执行以下命令:
apt-get update

第一步命令输入以下内容:

mysql-server:
  Installed: (none)
  Candidate: 8.0.37-0ubuntu0.20.04.3
  Version table:
     8.0.37-0ubuntu0.20.04.3 500
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates/main amd64 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates/main i386 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security/main amd64 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security/main i386 Packages
     8.0.19-0ubuntu5 500
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal/main amd64 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal/main i386 Packages

可以看到只有8.0版本。

以下通过更换安装源的方式,切换5.7版本。

首先在/etc/apt/sources.list文件中添加以下安装源:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

接着需要安装证书:
gpg --keyserver keyserver.ubuntu.com --recv 3B4FE6ACC0B21F32
gpg --export --armor 3B4FE6ACC0B21F32 | apt-key add -

最后刷新一下缓存:
apt-get update

再次执行命令:
apt-cache policy mysql-server

输出以下内容:

mysql-server:
  Installed: (none)
  Candidate: 8.0.37-0ubuntu0.20.04.3
  Version table:
     8.0.37-0ubuntu0.20.04.3 500
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates/main amd64 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates/main i386 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security/main amd64 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security/main i386 Packages
     8.0.19-0ubuntu5 500
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal/main amd64 Packages
        500 http://mirrors.cloud.aliyuncs.com/ubuntu focal/main i386 Packages
     5.7.42-0ubuntu0.18.04.1 500
        500 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 Packages
        500 http://mirrors.aliyun.com/ubuntu bionic-security/main i386 Packages
        500 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages
        500 http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 Packages
     5.7.21-1ubuntu1 500
        500 http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages
        500 http://mirrors.aliyun.com/ubuntu bionic/main i386 Packages

此时就可以通过apt-get命令安装5.7版本了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值