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




相关推荐
cfm_29143 小时前
Redis缓存规范设计与全方位性能优化实战
redis·缓存·性能优化
weelinking3 小时前
【产品】12_接入数据库——让数据永久保存
jvm·数据库·python·react.js·数据挖掘·前端框架·产品经理
稳联技术老娜3 小时前
DeviceNet主站怎么连接西门子PLC,Profinet网关配置手册(那智机器人)
服务器·网络·数据库
这个DBA有点耶4 小时前
云上运维新挑战:当数据库不再“看得见摸得着”
数据库·sql·程序人生·云原生·运维开发·学习方法·dba
AskHarries5 小时前
系统提示词、开发者指令和用户输入的优先级
java·前端·数据库
消失在人海中5 小时前
oracle 数据库多表关联查询
服务器·数据库·oracle
九皇叔叔5 小时前
PostgreSQL/openGauss pg_stats 视图从入门到精通:统计信息、执行计划与慢 SQL 优化实战
数据库·sql·postgresql
南极企鹅6 小时前
MySQL间隙锁&临键锁
数据库·sql·mysql
TDengine (老段)7 小时前
TDengine 压缩编码机制 — 双层压缩架构与类型特化算法
大数据·数据库·物联网·算法·时序数据库·tdengine·涛思数据
苏渡苇8 小时前
Redis 持久化——RDB 快照 vs AOF 日志
数据库·redis·缓存·redis持久化·aof vs rdb