CentOS 7 安装 MySQL 8.0 踩坑全记录与终极解决方案

一、问题复盘:从报错到根因定位

1. 初始问题:MySQL 官方源安装超时

执行命令 yum -y install https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm 时,反复报错:

bash 复制代码
[root@iZ0jlgpxxeb31ngiadjy9gZ java]#  yum -y install https://repo.mysql.com//mysql80-community-release-el7-7.noarch.rpm
Last metadata expiration check: 4:13:36 ago on Wed 13 May 2026 07:44:59 AM CST.
[MIRROR] mysql80-community-release-el7-7.noarch.rpm: Curl error (28): Timeout was reached for https://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm [Connection timed out after 30000 milliseconds]
[MIRROR] mysql80-community-release-el7-7.noarch.rpm: Curl error (28): Timeout was reached for https://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm [Connection timed out after 30000 milliseconds]
[MIRROR] mysql80-community-release-el7-7.noarch.rpm: Curl error (28): Timeout was reached for https://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm [Connection timed out after 30001 milliseconds]
[MIRROR] mysql80-community-release-el7-7.noarch.rpm: Curl error (28): Timeout was reached for https://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm [Connection timed out after 30000 milliseconds]
[FAILED] mysql80-community-release-el7-7.noarch.rpm: Curl error (28): Timeout was reached for https://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm [Connection timed out after 30000 milliseconds]
Curl error (28): Timeout was reached for https://repo.mysql.com/mysql80-community-release-el7-7.noarch.rpm [Connection timed out after 30000 milliseconds]
[root@iZ0jlgpxxeb31ngiadjy9gZ java]#

二、分步解决方案:从排查到安装

测试域名解析与连接

bash 复制代码
ping repo.mysql.com
curl -v https://repo.mysql.com

如果无法 ping 通,说明服务器无法访问该域名,优先使用国内源。

失败了

使用阿里云镜像源(最稳定)

直接替换为国内镜像,彻底解决超时问题:

清理之前失败的安装

bash 复制代码
yum remove -y mysql80-community-release-el7-7.noarch

rm -rf /etc/yum.repos.d/mysql-community*

配置阿里云 MySQL 8.0 源

bash 复制代码
cat > /etc/yum.repos.d/mysql-community.repo << EOF
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=https://mirrors.aliyun.com/mysql/yum/mysql80-community/el/7/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/mysql/RPM-GPG-KEY-mysql-2022
EOF

导入 GPG 密钥并刷新缓存

bash 复制代码
rpm --import https://mirrors.aliyun.com/mysql/RPM-GPG-KEY-mysql-2022

yum clean all && yum makecache

linux 安装mysql8




相关推荐
SelectDB3 小时前
阶跃星辰基于 SelectDB 构建 PB 级 Agent 可观测平台
大数据·数据库·aigc
这个DBA有点耶4 小时前
GROUP BY优化全解:如何写出既不丢数据又飞快的分组查询
数据库·mysql·架构
掉头发的王富贵7 小时前
【StarRocks】极限十分钟入门StarRocks
数据库·sql·mysql
Nturmoils7 小时前
WHERE 条件别凭习惯写,常用查询先跑一遍
数据库
云技纵横10 小时前
一个 @Async 让循环依赖暴雷:Spring 代理的暗坑
redis
Databend1 天前
在 AWS 中国峰会逛了一天,我在 Databend 展台看到了 Agent 数据基础设施的新思路
数据库·人工智能·agent
犯困蛋挞yy1 天前
用Claude快速解决Redis代码报错反复无解的问题
redis
小七-七牛开发者2 天前
TokenPilot:让 LLM Agent 长会话成本降 60%+ 的上下文管理
缓存·agent·token·context·上下文·推理成本
ClouGence2 天前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
飞将2 天前
从零实现数据库(2)——HashIndex + IndexManager
数据库