无法在 Amazon Linux 2023 上安装 MySql

无法在 Amazon Linux 2023 上安装 MySql

我正在运行 Amazon Linux 2023.4.20240319 的 EC2(AWS) 计算机上工作。我需要安装apache、php和mysql。我坚持使用mysql。我遵循了在互联网上找到的许多说明:

但最后一个错误没有解决方案:

$ sudo yum --enablerepo=mysql80-community install mysql-community-server
MySQL 8.0 Community Server                                      37  B/s |  10  B     00:00    
Errors during downloading metadata for repository 'mysql80-community':
  - Status code: 404 for http://repo.mysql.com/yum/mysql-8.0-community/fc/2023.4.20240319/aarch64/repodata/repomd.xml (IP: 23.213.17.14)
Error: Failed to download metadata for repo 'mysql80-community': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: mysql80-community
Last metadata expiration check: 0:14:52 ago on Wed Mar 27 14:50:32 2024.
No match for argument: mysql-community-server
Error: Unable to find a match: mysql-community-server

我已卸载软件包并清理缓存,然后重试,但结果相同。

请问我该如何修复它?

更新

mysql在默认 yum 存储库中不可用

$ sudo dnf search mysql
Last metadata expiration check: 1:53:50 ago on Wed Mar 27 14:50:32 2024.
================================ Name & Summary Matched: mysql ================================apr-util-mysql.aarch64 : APR utility library MySQL DBD driver
bind-dlz-mysql.aarch64 : BIND server mysql and mysqldyn DLZ modules
collectd-mysql.aarch64 : MySQL plugin for collectd
dovecot-mysql.aarch64 : MySQL back end for dovecot
mysql-selinux.noarch : SELinux policy modules for MySQL and MariaDB packages
mysql80-community-release.noarch : MySQL repository configuration for yum
perl-DBD-MySQL.aarch64 : A MySQL interface for Perl
perl-DateTime-Format-MySQL.noarch : Parse and format MySQL dates and times
php8.1-mysqlnd.aarch64 : A module for PHP 8.1 applications that use MySQL databases
php8.2-mysqlnd.aarch64 : A module for PHP 8.2 applications that use MySQL databases
postfix-mysql.aarch64 : Postfix MySQL map support
=================================== Summary Matched: mysql ====================================mariadb105-devel.aarch64 : Files for development of MariaDB/MySQL applications
mariadb105-server-utils.aarch64 : Non-essential server utilities for MariaDB/MySQL applicationsperl-DBD-MariaDB.aarch64 : MariaDB and MySQL driver for the Perl5 Database Interface (DBI)

答案1

您以为自己使用的是 Fedora,但实际上使用的是 Amazon Linux 2023。

获取 MySQL 服务器的推荐方法是安装 MariaDB 软件包(请参阅这个另一个答案有关 MariaDB 与 MySQL 的讨论)。如果您只想将其与 PHP 一起使用,那么我不建议采用不受支持的路线并添加第三方存储库。

一个简单的

dnf install mariadb105-server
# if you use a future version of amazon linux:
# dnf install mariadb\*-server
# to get whatever the system has

将为您提供一个 MySQL 服务器,您的 amazon Linux 上的所有其他 mysql/mariadb 工具都是针对该服务器构建的。

答案2

你说这是普通的软呢帽,所以很简单

sudo dnf install mysql

将安装MySQL服务器。完毕!

(您可能会注意到,您获得的软件包可能被称为mariadb,但这并不会改变您获得 MySQL 的事实。只是现在称为“MySQL”的软件是原始 MySQL 的一个分支,在由于 Oracle 的商业原因,“MariaDB”是最初称为“MySQL”的不同分支,它继续面向社区的开发,如果您想要 LAMP 设置,您通常需要 MariaDB,而不是新的 MySQL。 ,除非您与 Oracle 签订了昂贵的服务合同 - 但我猜您不会来这里寻求安装建议,而是使用他们的服务。)


结果您使用的是 Amazon Linux,而不是 Fedora。尝试安装dnf install mariadb.

答案3

这是对此的完整描述回复

登录后(使用 Putty 或 Termius),我运行了以下命令:

$ sudo wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm 

$ sudo dnf install mysql80-community-release-el9-1.noarch.rpm -y

$ sudo dnf install mysql-community-server -y

此时我遇到错误:

MySQL 8.0 Community Server                                     3.0 MB/s | 3.1 kB     00:00    
GPG key at file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 (0x3A79BD29) is already installed
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.36-1.el9.aarch64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Public key for mysql-community-client-plugins-8.0.36-1.el9.aarch64.rpm is not installed. Failing package is: mysql-community-client-plugins-8.0.36-1.el9.aarch64

我用命令解决了它:

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

然后

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

$ sudo systemctl start mysqld

资料来源:

相关内容