无法在CENTOS7上安装MySQL。

8

我使用的是CentOS 7(CentOS Linux release 7.9.2009 (Core))操作系统,从头开始在新服务器上安装MySQL(版本7或8)。

我按照自己以及其他网站如下成功完成过的步骤进行了尝试:

所有这些方式都同意以下步骤:

  1. Download and add the following MySQL Yum repository

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

    Note I tried different versions 7-5, and 8

  2. install the downloaded package

    sudo yum install mysql80-community-release-el7-3.noarch.rpm -y
  3. install MySQL:

    sudo yum install mysql-server -y
在第三步安装失败。
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)

我阅读了这篇帖子,看起来很相似,但还是没有成功。

目前我只能成功安装一个非常古老的mysql版本:5.6。

有什么想法/建议吗?我缺少什么,或者如何解决这个问题?


那个发行版不是已经超过生命周期了吗? - orhtej2
最近RedHat放弃了CentOS。为什么你还想在一个正在消亡的操作系统上工作呢?不久的将来,支持也会逐渐消失。 - The Impaler
2
感谢你们的评论。|| CentOS7的EOF是2024年。|| CentO8在去年12月突然结束了。|| CentOS7就是它所拥有的。 - user3891775
它仍在接收非安全更新吗? - orhtej2
如果是新服务器,我仍然会考虑使用不同的发行版。 - orhtej2
4个回答

62

我想我明白了。这是我用来解决它的方法。

### 步骤#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/

### 第二步:设置Yum仓库 ###

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

### 第三步:禁用 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步 - 重新运行第3步安装MySQL Community Server ###

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

收到多个与不同语言相关的警告消息;例如与“英语”相关的消息。

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


1
伟大的侦探工作 - orhtej2
太棒了,非常感谢! - user453575457
解决方案只是执行以下命令:(rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022)。 - mohaa8844
我确认这种方法可行!谢谢你,伙计! - Jamviet.com
3
@ShubhamSrivastava - 上述步骤仅用于软件包设置: 完成上述步骤后,您需要执行以下操作: A)获取默认密码: MySQL 8.0或更高版本在安装后会在/var/log/mysqld.log中生成一个临时随机密码。 要查看密码,请运行: sudo grep 'password' /var/log/mysqld.log 响应:为root@localhost生成了临时密码B)运行安全安装 sudo mysql_secure_installation - user3891775
显示剩余4条评论

9

在我的情况下,我只是导入了 GPG-KEY:

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

然后,接下来的命令运行没有错误:

sudo yum install mysql-server -y

[ec2-user@ip html]$ sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 [ec2-user@ip html]$ sudo yum install mysql-server -y 上次元数据过期检查:2小时58分钟23秒前,于2023年9月19日12:15:01。 找不到匹配项:mysql-server 错误:无法找到匹配项:mysql-server - undefined
有没有办法解决这个问题? - undefined

0
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

它确实做到了魔法。


你的回答可以通过提供更多支持信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的答案是正确的。您可以在帮助中心找到有关如何编写良好答案的更多信息。 - Community

0

在第四步之后,我遇到了一个问题,出现了错误:

my.cnf from install of mysql-community-server-8.0.32-1.el7.x86_64 conflicts with file from package MariaDB-common...

我需要运行:

yum remove mariadb-libs

然后安装MYSQL。在这里找到了 MySQL won't install in CentOS due to conflict with mariadb

安装MYSQL后顺利进行。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接