¿Cómo solucionar el error ‘GPG key is already installed’ al instalar MySQL en Amazon Linux 2023?
December 22, 2024

¿Cómo solucionar el error ‘GPG key is already installed’ al instalar MySQL en Amazon Linux 2023?

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.
Enter full screen mode

Exit full screen mode

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
Enter full screen mode

Exit full screen mode

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  
Enter full screen mode

Exit full screen mode

3. Retry MySQL installation

Now you can reinstall MySQL without any problems:

   sudo yum install mysql-community-server -y  
Enter full screen mode

Exit full screen mode




Check activity key

To confirm that the correct key is installed, use the following command:

rpm -qa gpg-pubkey
Enter full screen mode

Exit full screen mode

You should see something similar to the following:

gpg-pubkey-a8d3785c-
Enter full screen mode

Exit full screen mode

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. 😊

2024-12-22 20:08:18

Leave a Reply

Your email address will not be published. Required fields are marked *