阿里云CentOS7安装MySQL5.7成功2022年亲测

Posted 小基基o_O

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阿里云CentOS7安装MySQL5.7成功2022年亲测相关的知识,希望对你有一定的参考价值。

前言

在虚拟机安装mysql5.7没问题,在阿里云装MySQL5.6也没问题
但是,2022年2月,新购的阿里云服务器装MySQL5.7各种报错信息:

执行yum -y install mysql-server报错如下

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

然后执行systemctl start mysqld报错如下

Failed to start mysqld.service: Unit not found.

经过一番摸索,发现是/etc/yum.repos.d/mysql-community.repo中MySQL5.7的gpgcheck=1

GPG签名主用于Linux实现官方发布的包的签名机制,用于软件下载的安全
gpgcheckGPG签名是否开启的选项:1开启,0不开启

完整安装步骤

  1. 更新 YUM
yum -y update
  1. 下载MySQL的RPM
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
  1. 安装MySQL相关依赖
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
  1. 编辑/etc/yum.repos.d/mysql-community.repo
    [mysql57-community]gpgcheck=1改成gpgcheck=0
vim /etc/yum.repos.d/mysql-community.repo
  1. 安装MySQL服务
yum -y install mysql-server
  1. 启动MySQL服务
systemctl start mysqld
  1. 查看密码
cat /var/log/mysqld.log | grep password
  1. 使用上述密码登录
mysql -uroot -p

  1. 后面的操作:
https://yellow520.blog.csdn.net/article/details/113036158

以上是关于阿里云CentOS7安装MySQL5.7成功2022年亲测的主要内容,如果未能解决你的问题,请参考以下文章

阿里云 CentOS7.4 环境安装mysql5.7

阿里云centos7.3下安装mysql5.7.19

阿里云ECS下基于Centos7.4安装MySQL5.7.20

CentOS7安装mysql5.7

在 CentOS7 上安装 MySQL5.7

阿里云服务器CentOS7.3上通过Docker安装MySQL