在 Amazon Linux 2023 上如何安装 MySQL 客户端

Amazon Linux 2023(AL2023)最近发布了,这个发行版是专门应对亚马逊云服务器设计的操作系统,基于Fedora (但不确定是34?35?36?)进行了定制,与AL2022相比,AL2023采用默认安全方法,通过预先配置的安全策略、默认启用SELinux 和 IMDSv2、内核强化和实时补丁来帮助改善安全状况。并且从AL2023 开始,新的Amazon Linux主要版本将每2年发布一次。

cecbfea8aa115356

但是在我安装上AL2023之后尝试安装MySQL,发现MySQL已经没有包含在默认的库里,需要按照MySQL官方的库文件进行安装。于是就有了这篇文章,以下操作在EC2的t4g.nano实例(aarch64)得到验证。

安装MySQL客户端

默认安装好AL2023之后,你可以执行命令检查一下系统库是否包含了MySQL:

# dnf search mysql
Amazon Linux 2023 repository                                                            2.3 MB/s |  11 MB     00:04
Last metadata expiration check: 0:00:04 ago on Thu Mar 24 11:27:01 2023.
============================================ Name & Summary Matched: mysql =============================================
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
bind-dlz-mysql.x86_64 : BIND server mysql and mysqldyn DLZ modules
collectd-mysql.x86_64 : MySQL plugin for collectd
mysql-selinux.noarch : SELinux policy modules for MySQL and MariaDB packages
perl-DBD-MySQL.x86_64 : A MySQL interface for Perl
perl-DateTime-Format-MySQL.noarch : Parse and format MySQL dates and times
php8.1-mysqlnd.x86_64 : A module for PHP 8.1 applications that use MySQL databases
postfix-mysql.x86_64 : Postfix MySQL map support
================================================ Summary Matched: mysql ================================================
mariadb105-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb105-server-utils.x86_64 : Non-essential server utilities for MariaDB/MySQL applications
perl-DBD-MariaDB.x86_64 : MariaDB and MySQL driver for the Perl5 Database Interface (DBI)

虽然AL2023是基于Fedora的,但是用fedora的包安装会出错,用RHEL9的包可以安装。

# dnf -y localinstall  https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm
# dnf -y install mysql mysql-community-client
Last metadata expiration check: 0:00:14 ago on Thu Mar 24 11:37:50 2023.
Dependencies resolved.
========================================================================================================================
 Package                                Architecture   Version                          Repository                 Size
========================================================================================================================
Installing:
 mysql-community-client                 x86_64         8.0.32-1.el9                     mysql80-community         3.9 M
Installing dependencies:
 cyrus-sasl-lib                         x86_64         2.1.27-18.amzn2023.0.3           amazonlinux               786 k
 mysql-community-client-plugins         x86_64         8.0.32-1.el9                     mysql80-community         1.4 M
 mysql-community-common                 x86_64         8.0.32-1.el9                     mysql80-community         544 k
 mysql-community-libs                   x86_64         8.0.32-1.el9                     mysql80-community         1.5 M
 systemd-libs                           x86_64         252.4-1161.amzn2023.0.3          amazonlinux               631 k

Transaction Summary
========================================================================================================================
Install  6 Packages

Total size: 8.7 M
Installed size: 100 M
Is this ok [y/N]:

这个方法仅适用于mysql-community-client客户端的安装,服务端mysql-community-server(mysqld)安装后无法启用。

最后的建议

如无特殊情况,建议转向MariaDB,MariaDB在AL2023官方仓库中就有提供,使用起来与MySQL差异不会太大。

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享