If you are trying to install MySQL on an EC2 instance Amazon Linux 2023you may encounter annoying errors related to GPG keys:
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.
This happens because MySQL recently updated its GPG keys, and some versions of the repository try to use outdated keys. Here’s how to fix this problem and why it occurs.
What causes this error?
GPG keys are used to verify the integrity and authenticity of downloaded packages. However, the old key RPM-GPG-KEY-mysql-2022
Expired December 14, 2023while newer packages (starting with MySQL 8.0.36) now require a new key RPM-GPG-KEY-mysql-2023
Therefore, even if the repository automatically configures the old key, it cannot verify the new package.
How to fix this error
Please follow the steps below to import the new GPG key and complete the MySQL installation.
1. Remove outdated GPG keys
Be sure to delete any old keys that may cause conflicts.
sudo rpm -e gpg-pubkey-3a79bd29
use: 3a79bd29
This is the old key. If you see another conflicting key in the error message, replace it with the corresponding identifier.
2. Import new GPG keys starting in 2023
Manually download and import the new GPG key:
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
3. Retry MySQL installation
Now you can reinstall MySQL without any problems:
sudo yum install mysql-community-server -y
Check activity key
To confirm that the correct key is installed, use the following command:
rpm -qa gpg-pubkey
You should see something similar to the following:
gpg-pubkey-a8d3785c-
identifier a8d3785c
Corresponds to the new GPG key valid for the latest MySQL package.
Looking to the future
according to MySQL error reportingthese keys are updated regularly. This is a good practice:
- Be sure to check the release notes or official MySQL documentation.
- Verify the validity of the GPG key before installing or updating software packages.
in conclusion
This problem may seem frustrating, but now that you know how to fix it, you will be able to successfully install MySQL on an EC2 instance running Amazon Linux 2023.
If you have any questions or encounter other errors, please leave them in the comments! I’m here to help you. 😊