无法在 CENTOS7 上安装 MySQL

Unable to install MySQL on CENTOS7

我在 CentOS 7(CentOS Linux 7.9.2009 版(核心版))上从头开始在新服务器上尝试安装 MySQL(7 或 8)。

我已经按照我的步骤进行了 - 我在过去已经成功完成了很多次,还有许多其他网站,例如:

和许多其他人

所有方法都同意这些步骤:

  1. 下载并添加以下内容MySQL Yum 存储库

    sudo wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm</pre>
    

    注意 我尝试了不同的版本 7-5 和 8

  2. 安装下载的包

    sudo yum install mysql80-community-release-el7-3.noarch.rpm -y</pre>
    
  3. 安装MySQL:

    sudo yum install mysql-server -y</pre>
    

第 3 步是安装失败的地方

mysql -V
-bash: mysql: command not found

我得到了所有这些错误

Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libtirpc.so.3()(64bit)
Error: Package: mysql-community-libs-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: mysql-community-client-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: mysql-community-libs-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: mysql-community-client-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libtirpc.so.3(TIRPC_0.3.3)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.22)(64bit)
Error: Package: mysql-community-client-plugins-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: mysql-community-client-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: mysql-community-client-plugins-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: mysql-community-libs-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: mysql-community-client-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: mysql-community-client-plugins-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: mysql-community-client-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libncurses.so.6()(64bit)
Error: Package: mysql-community-client-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libtinfo.so.6()(64bit)
Error: Package: mysql-community-libs-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.11)(64bit)
Error: Package: mysql-community-client-plugins-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libc.so.6(GLIBC_2.25)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: mysql-community-server-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libtirpc.so.3(TIRPC_0.3.0)(64bit)
Error: Package: mysql-community-client-plugins-8.0.28-1.el8.x86_64 (mysql80-community)
           Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)

我读了这个 post 看起来很相似,但也不走运

我能够成功安装的唯一版本是一个非常旧的 mysql 版本:5.6

关于我遗漏的任何 ideas/suggestions;或者如何解决这个问题?

我想我明白了。这是我为解决它所做的。

### 步骤 #1:- 删除以前安装的包并清除缓存 ###

# look for the mysql installed packages
sudo yum list installed | grep mysql

sudo yum remove mysql80-community-release.noarch

sudo yum clean all --verbose

#manually remove remaining mysql cache folders
#from: https://serverfault.com/questions/1028593/mysql-packages-skipped-dependency-problems
sudo rm -R /var/cache/yum/x86_64/7/mysql*

sudo yum update

来自:https://tecadmin.net/install-mysql-8-on-centos/

### 步骤 #2:– 设置 Yum 存储库 ###

rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

### 步骤 #3:– 禁用 mysql 回购文件中的所有存储库。 ###

sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

### 步骤 #4 – 安装 MySQL 社区服务器 ###

yum --enablerepo=mysql80-community install mysql-community-server 

出现以下错误:

The GPG keys listed for the "MySQL 8.0 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-client-8.0.28-1.el7.x86_64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

来自 https://forums.cpanel.net/threads/mysql-upgrade-process-failed-the-gpg-keys-listed-for-the-mysql-8-0-community-server-repository-are-already-installed-but-they-are-not-correct-for.697213/

### 步骤 #5 – 导入新的 GPG 密钥 ###

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

### 步骤 #6 – Re-run 步骤 #3 安装 MySQL 社区服务器 ###

yum --enablerepo=mysql80-community install mysql-community-server

收到与每种不同语言相关的多条警告消息;例如与 'english'

有关的那个
warning: file /usr/share/mysql/english/errmsg.sys: remove failed: No such file or directory
warning: file /usr/share/mysql/english: remove failed: No such file or directory

然而,最后的消息是成功的:

Installed:
  mysql-community-libs.x86_64 0:8.0.28-1.el7                                                  
  mysql-community-libs-compat.x86_64 0:8.0.28-1.el7                                           
  mysql-community-server.x86_64 0:8.0.28-1.el7                                                

Dependency Installed:
  mysql-community-client.x86_64 0:8.0.28-1.el7                                                
  mysql-community-client-plugins.x86_64 0:8.0.28-1.el7                                        
  mysql-community-common.x86_64 0:8.0.28-1.el7                                                
  mysql-community-icu-data-files.x86_64 0:8.0.28-1.el7                                        

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                                          

Complete!

### 步骤#7:测试###

mysql -V

# output #
mysql Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)

### 步骤 #8:仔细检查 运行 yum 更新时没有错误 ###

sudo yum update

通过手动启动确认,检查状态,

sudo systemctl start mysqld
sudo systemctl status mysqld

rpm -qa | grep mariadb



rpm -e XXX #If there is an already installed mariadb, uninstall it



rpm -e --nodeps xxx //If the preceding delete action does not work, try force delete

它真的很神奇。

在我的例子中,我刚刚导入了 GPG-KEY:

sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

之后下一个命令运行无误:

sudo yum install mysql-server -y