记录无法安装mysql-InvalidGPGKeyfromfile:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql的解决办法
问题描述
在安装mysql时,可能会遇到以下错误:
Error: Failed to download metadata for repo 'mysql56-community': Cannot prepare internal mirrorlist: Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql]
或者
warning: /var/cache/yum/x86_64/7/mysql-connectors-community/packages/mysql-connector-python-2.1.3-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql-community-release-el7-5.noarch (@/mysql-community-release-el7-5.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]:
这是由于系统缺少mysql官方的GPG秘钥文件所致。如果没有正确的密钥,yum 安装 MySQL 将失败。
解决办法
步骤一:下载官方密钥文件
下载官方密钥文件,命令如下:
$ sudo wget https://repo.mysql.com/RPM-GPG-KEY-mysql
步骤二:移动官方密钥文件到/etc/pki/rpm-gpg/
将下载的官方密钥文件移动到 /etc/pki/rpm-gpg/
目录下,命令如下:
$ sudo mv RPM-GPG-KEY-mysql /etc/pki/rpm-gpg/
步骤三:安装 MySQL
安装 MySQL,指定 MySQL 版本,命令如下:
$ sudo yum install -y http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ sudo yum install -y mysql-community-server
示例说明
示例一
在 CentOS 7 上安装 MySQL,遇到以下报错:
warning: /var/cache/yum/x86_64/7/mysql-connectors-community/packages/mysql-connector-python-2.1.3-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql-community-release-el7-5.noarch (@/mysql-community-release-el7-5.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]:
按照以上步骤,下载 mysql 的官方 GPG 秘钥文件并且将其移动至 /etc/pki/rpm-gpg/
目录下,然后执行安装命令:
$ sudo yum install -y http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ sudo yum install -y mysql-community-server
示例二
在安装 mysql 时,遇到以下报错:
Error: Failed to download metadata for repo 'mysql56-community': Cannot prepare internal mirrorlist: Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql]
同样按照以上步骤,下载 mysql 的官方 GPG 秘钥文件并且将其移动至 /etc/pki/rpm-gpg/
目录下,然后执行安装命令:
$ sudo wget https://repo.mysql.com/RPM-GPG-KEY-mysql
$ sudo mv RPM-GPG-KEY-mysql /etc/pki/rpm-gpg/
$ sudo yum install -y http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ sudo yum install -y mysql-community-server
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:记录无法安装mysql-Invalid GPG Key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql的解决办法 - Python技术站