これはなに
久々にRDSに触れる機会がありましたが、mysqlコマンドが使用できなくなっていたので検証します
該当エラー
Amazon Linux 2023にmysqlをインストールしようとしたらエラーが発生してしまった
$sudo dnf install mysql No match for argument: mysql Error: Unable to find a match: mysql
これを解消するための手順を検証します
原因
このエラーがなぜ起きたのか調べてみると標準リポジトリにmysqlが含まれていないためにエラーが発生してしまっているようです
そのためリポジトリをインストールするところから検証します
$ sudo dnf info mysql-community-server Last metadata expiration check: 0:06:36 ago on Wed Mar 26 05:20:53 2025. Error: No matching Packages to list
検証する
以下コマンドでMySQL 8.0 の公式リポジトリをインストール
$ sudo dnf localinstall https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm Last metadata expiration check: 1:04:46 ago on Tue Mar 25 10:35:14 2025. mysql80-community-release-el9-1.noarch.rpm 48 kB/s | 10 kB 00:00 Dependencies resolved. ==================================================================================================================================================================================================== Package Architecture Version Repository Size ==================================================================================================================================================================================================== Installing: mysql80-community-release noarch el9-1 @commandline 10 k Transaction Summary ==================================================================================================================================================================================================== Install 1 Package Total size: 10 k Installed size: 5.7 k Is this ok [y/N]: y Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : mysql80-community-release-el9-1.noarch 1/1 Verifying : mysql80-community-release-el9-1.noarch 1/1 Installed: mysql80-community-release-el9-1.noarch Complete!
以下コマンドでMySQL Community Client をインストール
$ sudo dnf install mysql mysql-community-client MySQL 8.0 Community Server 29 MB/s | 2.3 MB 00:00 MySQL Connectors Community 4.4 MB/s | 74 kB 00:00 MySQL Tools Community 26 MB/s | 946 kB 00:00 Dependencies resolved. ==================================================================================================================================================================================================== Package Architecture Version Repository Size ==================================================================================================================================================================================================== Installing: mysql-community-client x86_64 8.0.41-1.el9 mysql80-community 3.4 M Installing dependencies: mysql-community-client-plugins x86_64 8.0.41-1.el9 mysql80-community 1.4 M mysql-community-common x86_64 8.0.41-1.el9 mysql80-community 556 k mysql-community-libs x86_64 8.0.41-1.el9 mysql80-community 1.5 M Transaction Summary ==================================================================================================================================================================================================== Install 4 Packages Total download size: 6.8 M Installed size: 96 M Is this ok [y/N]: y Downloading Packages: (1/4): mysql-community-common-8.0.41-1.el9.x86_64.rpm 9.8 MB/s | 556 kB 00:00 (2/4): mysql-community-client-plugins-8.0.41-1.el9.x86_64.rpm 9.4 MB/s | 1.4 MB 00:00 (3/4): mysql-community-libs-8.0.41-1.el9.x86_64.rpm 15 MB/s | 1.5 MB 00:00 (4/4): mysql-community-client-8.0.41-1.el9.x86_64.rpm 20 MB/s | 3.4 MB 00:00 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 39 MB/s | 6.8 MB 00:00 MySQL 8.0 Community Server 3.0 MB/s | 3.1 kB 00:00 Importing GPG key 0x3A79BD29: Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>" Fingerprint: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 Is this ok [y/N]: y Key imported successfully Import of key(s) didn't help, wrong key(s)? Public key for mysql-community-client-8.0.41-1.el9.x86_64.rpm is not installed. Failing package is: mysql-community-client-8.0.41-1.el9.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 Public key for mysql-community-client-plugins-8.0.41-1.el9.x86_64.rpm is not installed. Failing package is: mysql-community-client-plugins-8.0.41-1.el9.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 Public key for mysql-community-common-8.0.41-1.el9.x86_64.rpm is not installed. Failing package is: mysql-community-common-8.0.41-1.el9.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 Public key for mysql-community-libs-8.0.41-1.el9.x86_64.rpm is not installed. Failing package is: mysql-community-libs-8.0.41-1.el9.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 The downloaded packages were saved in cache until the next successful transaction. You can remove cached packages by executing 'dnf clean packages'. Error: GPG check FAILED
別のエラーが出てしまった
エラー文を確認するとGPGキーに問題がありそうなので調べてみた
現在はGPG-KEY-mysql-2022が使われているがこいつが良くないみたい
確認してみるとGPG-KEY-mysql-2023が出ていたのでこちらを使ってみる
参照:https://repo.mysql.com/
#新しい方のGPGキーをインストール $ sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 #DNFキャッシュをクリアして、新しいキーが認識されるようにする $ sudo dnf clean all 38 files removed
この状態で再度MySQLのインストールを実行してみる
$ sudo dnf install mysql-community-server Amazon Linux 2023 repository 61 MB/s | 33 MB 00:00 Amazon Linux 2023 Kernel Livepatch repository 121 kB/s | 14 kB 00:00 MySQL 8.0 Community Server 44 MB/s | 2.3 MB 00:00 MySQL Connectors Community 2.0 MB/s | 74 kB 00:00 MySQL Tools Community 25 MB/s | 946 kB 00:00 Dependencies resolved. ==================================================================================================================================================================================================== Package Architecture Version Repository Size ==================================================================================================================================================================================================== Installing: mysql-community-server x86_64 8.0.41-1.el9 mysql80-community 50 M Installing dependencies: mysql-community-client x86_64 8.0.41-1.el9 mysql80-community 3.4 M mysql-community-client-plugins x86_64 8.0.41-1.el9 mysql80-community 1.4 M mysql-community-common x86_64 8.0.41-1.el9 mysql80-community 556 k mysql-community-icu-data-files x86_64 8.0.41-1.el9 mysql80-community 2.3 M mysql-community-libs x86_64 8.0.41-1.el9 mysql80-community 1.5 M Transaction Summary ==================================================================================================================================================================================================== Install 6 Packages Total download size: 59 M Installed size: 336 M Is this ok [y/N]: y Downloading Packages: (1/6): mysql-community-common-8.0.41-1.el9.x86_64.rpm 20 MB/s | 556 kB 00:00 (2/6): mysql-community-client-plugins-8.0.41-1.el9.x86_64.rpm 24 MB/s | 1.4 MB 00:00 (3/6): mysql-community-icu-data-files-8.0.41-1.el9.x86_64.rpm 20 MB/s | 2.3 MB 00:00 (4/6): mysql-community-libs-8.0.41-1.el9.x86_64.rpm 16 MB/s | 1.5 MB 00:00 (5/6): mysql-community-client-8.0.41-1.el9.x86_64.rpm 17 MB/s | 3.4 MB 00:00 (6/6): mysql-community-server-8.0.41-1.el9.x86_64.rpm 64 MB/s | 50 MB 00:00 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 63 MB/s | 59 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : mysql-community-common-8.0.41-1.el9.x86_64 1/6 Installing : mysql-community-client-plugins-8.0.41-1.el9.x86_64 2/6 Installing : mysql-community-libs-8.0.41-1.el9.x86_64 3/6 Running scriptlet: mysql-community-libs-8.0.41-1.el9.x86_64 3/6 Installing : mysql-community-client-8.0.41-1.el9.x86_64 4/6 Installing : mysql-community-icu-data-files-8.0.41-1.el9.x86_64 5/6 Running scriptlet: mysql-community-server-8.0.41-1.el9.x86_64 6/6 Installing : mysql-community-server-8.0.41-1.el9.x86_64 6/6 Running scriptlet: mysql-community-server-8.0.41-1.el9.x86_64 6/6 Verifying : mysql-community-client-8.0.41-1.el9.x86_64 1/6 Verifying : mysql-community-client-plugins-8.0.41-1.el9.x86_64 2/6 Verifying : mysql-community-common-8.0.41-1.el9.x86_64 3/6 Verifying : mysql-community-icu-data-files-8.0.41-1.el9.x86_64 4/6 Verifying : mysql-community-libs-8.0.41-1.el9.x86_64 5/6 Verifying : mysql-community-server-8.0.41-1.el9.x86_64 6/6 Installed: mysql-community-client-8.0.41-1.el9.x86_64 mysql-community-client-plugins-8.0.41-1.el9.x86_64 mysql-community-common-8.0.41-1.el9.x86_64 mysql-community-icu-data-files-8.0.41-1.el9.x86_64 mysql-community-libs-8.0.41-1.el9.x86_64 mysql-community-server-8.0.41-1.el9.x86_64 Complete!
問題なくインストールできた!
一応ダウンロードできてるかも確認しておく
$ sudo dnf install mysql Last metadata expiration check: 0:01:41 ago on Tue Mar 25 11:43:31 2025. Package mysql-community-client-8.0.41-1.el9.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete!
最後に
久しぶりに触ると今までできたことができなくなったりしているので修正方法や解決方法をナレッジとして貯めていきたいです。