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




相关推荐
Allen_LVyingbo9 分钟前
医疗AI基础2026-构建可靠智能体的编程路径(上)
大数据·数据库·人工智能·python·自动化
疯狂打码的少年13 分钟前
【数据库技术】多值依赖与第四范式(4NF)
数据库·笔记·算法
微软技术分享37 分钟前
Ubuntu 本地部署Ollama+OpenWebUI教程
数据库·ubuntu·postgresql
ly76891 小时前
MySQL 自增主键耗尽:从原理到应急恢复
数据库·mysql·innodb·故障恢复·自增主键·主键设计
文人sec1 小时前
MySQL主库出问题了,从库怎么办?备库为什么会延迟好几个小时?
android·数据库·mysql
砚底藏山河2 小时前
【量化纯GET实战 #23】多股票相关性:用收益率看板块联动
java·数据库·python·金融·数据分析
Java小白笔记2 小时前
MySQL 8.0 常用内置函数用例
数据库·mysql·mybatis
ZGG0032 小时前
MySQL 索引详解:B+ 树、聚簇索引与最左前缀
java·数据库·mysql
勿忘,瞬间3 小时前
Mybatis高阶
java·数据库·mybatis
运维行者_4 小时前
ISP 企业级带宽计费怎么做?网络流量计费的 6 大核心能力
运维·服务器·网络·数据库·支持向量机·接口隔离原则