Home >Database >Mysql Tutorial >How to fix &#GPG key is already installed&# error when installing MySQL on Amazon Linux 3?

How to fix &#GPG key is already installed&# error when installing MySQL on Amazon Linux 3?

Barbara Streisand
Barbara StreisandOriginal
2024-12-31 17:56:13939browse

¿Cómo solucionar el error

If you are trying to install MySQL on an EC2 instance with Amazon Linux 2023, you will probably encounter this annoying error 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 updated its GPG keys recently and some versions of the repository try to use outdated keys. Here's how to solve this problem and why it happens.


What causes this error?

GPG keys are used to verify the integrity and authenticity of downloaded packages. However, the old RPM-GPG-KEY-mysql-2022 key expired on December 14, 2023, and newer packages (starting with MySQL 8.0.36) now require the new RPM-key. GPG-KEY-mysql-2023

For this reason, even though the repository automatically configures the old key, it fails to verify newer packages.


How to resolve the error

Follow these steps to import the new GPG key and complete the MySQL installation.

1. Delete obsolete GPG keys

Be sure to remove any old keys that may be causing conflicts.

   sudo rpm -e gpg-pubkey-3a79bd29

Note: 3a79bd29 is the old key. If you see another conflicting key in the error messages, replace it with the corresponding identifier.

2. Import the new GPG key from 2023

Download and manually 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 problems:

   sudo yum install mysql-community-server -y  

Check active keys

To confirm that the correct keys are installed, use this command:

rpm -qa gpg-pubkey

You should see something like:

gpg-pubkey-a8d3785c-<timestamp>

The identifier a8d3785c corresponds to the new GPG key valid for recent MySQL packages.


A look into the future

According to the MySQL bug report, these keys are updated periodically. It is good practice:

  • Always consult the release notes or official MySQL documentation.
  • Verify the validity of the GPG keys before installing or updating packages.

Conclusion

This problem may seem frustrating, but now that you know how to solve it, you will be able to install MySQL without any problems on your EC2 instance running Amazon Linux 2023.

If you have any questions or encounter another error, leave it in the comments! I'm here to help you. ?

The above is the detailed content of How to fix &#GPG key is already installed&# error when installing MySQL on Amazon Linux 3?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn