ubuntu20.04 安装 MySQL5.7过程记录
作者:MaxFang 时间:2024-01-23 20:18:09
背景介绍#
ubuntu 20.04 版本系统自带的 MySQL 版本是 8.0,普通方法很难安装 5.7 版本的。由于 8.0 版本较 5.7 版本做了不少改动,笔者比较习惯使用 5.7 版本。
网上搜做了一圈,跟着各种教程试了很多遍,最后终于找到了成功的方法。过程记录分享出来,供大家参考。
安装过程#
笔者的环境:
root@hz192-168-1.55:/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根据实际情况替换。
root@hz192-168-1-55:/home# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
接着再重新执行更新,
sudo apt update
安装 MySQL
查看支持的 MySQL 版本,此处我们已经可以看到有 5.7.40-1ubuntu18.04,接近成功了。
root@hz192-168-1-55:/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
验证
root@hz192-168-1-55:/home# mysql --version
mysql ?Ver 14.14 Distrib 5.7.40, for Linux (x86_64) using ?EditLine wrapper
ok, 完结。踩坑君再次填好一个坑,接着去踩下一个啦。
来源:https://www.cnblogs.com/immaxfang/archive/2022/10/18/16804455.html
标签:mysql5.7安装
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SSM实现mysql数据库账号密码密文登录功能
2024-01-28 16:52:30
pytest测试框架+allure超详细教程
2023-03-18 21:38:00
![](https://img.aspxhome.com/file/2023/6/69506_0s.png)
jquery实现表单验证并阻止非法提交
2023-07-02 05:31:28
python中sleep函数用法实例分析
2023-10-19 15:33:24
Java使用JDBC连接数据库的详细步骤
2024-01-15 17:42:42
tensorflow: variable的值与variable.read_value()的值区别详解
2023-01-02 22:29:40
![](https://img.aspxhome.com/file/2023/5/85035_0s.jpg)
排序的人文魅力
2008-05-06 12:47:00
python 上下文管理器及自定义原理解析
2023-01-24 20:07:55
python自定义线程池控制线程数量的示例
2022-12-25 15:16:13
MySQL 搭建MHA架构部署的步骤
2024-01-17 05:27:10
![](https://img.aspxhome.com/file/2023/5/111365_0s.png)
windows 7安装ORACLE 10g客户端的方法分享
2012-07-11 15:36:18
TensorFlow实现简单线性回归
2023-09-18 13:23:45
![](https://img.aspxhome.com/file/2023/9/92519_0s.jpg)
用Python实现网易云音乐的数据进行数据清洗和可视化分析
2023-07-03 18:53:00
![](https://img.aspxhome.com/file/2023/8/85188_0s.png)
Apifox Echo学习curl httpie 命令使用详解
2022-06-19 22:33:00
![](https://img.aspxhome.com/file/2023/1/127201_0s.png)
Python入门篇之条件、循环
2021-09-16 16:10:00
js 实现拖拽排序详情
2024-06-07 15:24:23
Python实现迪杰斯特拉算法并生成最短路径的示例代码
2023-06-05 21:50:10
Mysql中的NULL和Empty String
2024-01-24 02:27:27
![](https://img.aspxhome.com/file/2023/1/71041_0s.png)
Matplotlib 绘制饼图解决文字重叠的方法
2023-06-12 22:23:06
![](https://img.aspxhome.com/file/2023/4/60504_0s.png)
SQL Server中读取XML文件的简单做法
2008-12-23 15:29:00