3

一、问题

在使用 apt-get update 在 Ubuntu 环境更新包资源时,出现了以下报错:

Ign http://repo.mysql.com trusty/mysql-tools Translation-en                    
Fetched 3,164 B in 1min 42s (30 B/s)                                           
Reading package lists... Done
W: GPG error: http://repo.mysql.com trusty InRelease: The following signatures were invalid: KEYEXPIRED 1487236823 KEYEXPIRED 1487236823 KEYEXPIRED 1487236823

从报错的信息看是因为签名参数过期了,所以,这里需要删除后再更新。

二、解决

先查看执行命令:apt-key list

root@iZ9:/var/www/html/gryphon# apt-key list
/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>
sub   2048g/79164387 2004-09-12

pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>

pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>

pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>

pub   4096R/0EBFCD88 2017-02-22
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

pub   1024D/5072E1F5 2003-02-03 [expired: 2017-02-16]
uid                  MySQL Release Engineering <mysql-build@oss.oracle.com>

/etc/apt/trusted.gpg.d/chris-lea-node_js.gpg
--------------------------------------------
pub   1024R/C7917B12 2010-05-17
uid                  Launchpad chrislea

/etc/apt/trusted.gpg.d/ondrej-php.gpg
-------------------------------------
pub   1024R/E5267A6C 2009-01-26
uid                  Launchpad PPA for Ondřej Surý

删除mysql 的repository GPG key,删除命令如下:

sudo apt-key del 5072E1F5

删除完了之后,检查还有没有那个mysql的key
没有了,执行命令

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 8C718D3B5072E1F5

输出:

root@iZ9:/var/www/html/gryphon# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 8C718D3B5072E1F5
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.RkicIHyEqq --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/chris-lea-node_js.gpg --keyring /etc/apt/trusted.gpg.d/ondrej-php.gpg --keyserver keyserver.ubuntu.com --recv 8C718D3B5072E1F5
gpg: requesting key 5072E1F5 from hkp server keyserver.ubuntu.com
gpg: key 5072E1F5: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1

我们再次查看:apt-key list

root@iZ94j7ehy5oZ:/var/www/html/gryphon# apt-key list
/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>
sub   2048g/79164387 2004-09-12

pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>

pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>

pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>

pub   4096R/0EBFCD88 2017-02-22
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

pub   1024D/5072E1F5 2003-02-03 [expires: 2022-02-16]
uid                  MySQL Release Engineering <mysql-build@oss.oracle.com>

/etc/apt/trusted.gpg.d/chris-lea-node_js.gpg
--------------------------------------------
pub   1024R/C7917B12 2010-05-17
uid                  Launchpad chrislea

/etc/apt/trusted.gpg.d/ondrej-php.gpg
-------------------------------------
pub   1024R/E5267A6C 2009-01-26
uid                  Launchpad PPA for Ondřej Surý

我们可以看到,mysql 的过期时间已经变为 2022-02-06 了

pub   1024D/5072E1F5 2003-02-03 [expires: 2022-02-16]
uid                  MySQL Release Engineering <mysql-build@oss.oracle.com>

然后我们再更新包:

apt-get update

Corwien
6.3k 声望1.6k 粉丝

为者常成,行者常至。