阿里云服务器Centos搭建mysql环境

本文档记录了在CentOS7系统中安装MySQL5.7时遇到的两个主要问题及其解决步骤。首先,由于CentOS7默认支持mariadb,安装MySQL会与mariadb文件冲突,需要先卸载mariadb。其次,在安装过程中出现GPG密钥不匹配的问题,需要导入正确的GPG密钥。通过这些步骤,最终成功安装了MySQL5.7社区服务器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

阿里云服务器Centos搭建mysql环境踩过的坑以及解决办法:

这里以MySQL5.7为例:
1 .下载并安装MySQL的 Yum Repository

[root@hzt ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

安装:

[root@hzt ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm

2.安装MySQL服务器

[root@hzt ~]# yum -y install mysql-community-server

这里会发现第一个问题:

Public key for mysql-community-server-5.7.37-1.el7.x86_64.rpm is not installed
 
 Failing package is: mysql-community-server-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

完整内容如下:

Total                                                 7.5 MB/s | 203 MB  00:26     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql57-community-release-el7-10.noarch (@/mysql57-community-release-el7-10.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


Public key for mysql-community-server-5.7.37-1.el7.x86_64.rpm is not installed


 Failing package is: mysql-community-server-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

原因:由于CentOS 7已经不支持MySQL了,取而代之在CentOS7内部集成了mariadb,而安装MySQL的话会和MariaDB的文件冲突。

3.查看centos自带的是 mariadb,将其卸载:

[root@hzt ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64

4.卸载mariadb

[root@hzt ~]# yum remove  -y  mariadb-libs-5.5.68-1.el7.x86_64

5.再次执行安装指令

[root@hzt ~]# yum -y install mysql-community-server

注意这里可能会出现第二个问题:

Install  1 Package (+4 Dependent packages)
Total size: 202 M
Installed size: 878 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-server-5.7.37-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.


 Failing package is: mysql-community-server-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.


 Failing package is: mysql-community-server-5.7.37-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

翻译为:“MySQL 5.7 Community Server”存储库列出的GPG密钥已经安装,但不适用于此软件包。检查是否为此存储库配置了正确的密钥URL。
失败的包是:mysql-community-server-5.7.37-1.el7.x86_64
GPG密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

6.在运行安装程序之前导入密钥:

[root@hzt ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

7.执行安装指令

[root@hzt ~]# yum -y install mysql-community-server

8.最终终于安装成功

........
Installed:
  mysql-community-server.x86_64 0:5.7.37-1.el7                                                          

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7                     mysql-community-client.x86_64 0:5.7.37-1.el7      
  mysql-community-common.x86_64 0:5.7.37-1.el7       mysql-community-libs.x86_64 0:5.7.37-1.el7        

Complete!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值