You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加MongoDB 7.0 GPG密钥后无法在apt-key列表中找到且apt update报错的解决方法咨询

添加MongoDB 7.0 GPG密钥后无法在apt-key列表中找到且apt update报错的解决方法咨询

Hey there, let's break down your issue and fix it step by step:

First off, the reason you don't see the key in sudo apt-key list is totally expected—modern Debian/Ubuntu systems have moved away from using apt-key to manage repository keys (it's actually deprecated now). Your command correctly added the key to /usr/share/keyrings/mongodb-server-7.0.gpg, which is the new recommended location, but apt-key list only shows keys stored in the old legacy keyrings (like /etc/apt/trusted.gpg or /etc/apt/trusted.gpg.d/).

The real problem here is likely that your MongoDB repository source file isn't configured to use this new keyring, which is why apt update is throwing errors. Here's how to fix it:

  • Check or create the MongoDB source list file
    You need to make sure there's a file in /etc/apt/sources.list.d/ that references your new keyring. Let's create it if it doesn't exist:

    sudo nano /etc/apt/sources.list.d/mongodb-org-7.0.list
    

    Paste the following line into the file (replace jammy with your Ubuntu version codename—like focal for 20.04, noble for 24.04):

    deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse
    

    Save the file (press Ctrl+O, then Enter, then Ctrl+X to exit nano).

  • Verify the key (optional but helpful)
    If you want to confirm the key was added correctly to the new keyring, run this command instead of apt-key list:

    gpg --no-default-keyring --keyring /usr/share/keyrings/mongodb-server-7.0.gpg --list-keys
    

    You should see the MongoDB 7.0 signing key listed here.

  • Run apt update again
    Now execute:

    sudo apt update
    

    This time, apt should recognize the keyring specified in the source list and verify the repository signatures without errors.

Just to recap: your key import was done the right way (using the new keyring location), the missing piece was linking that keyring to the MongoDB repository in your sources list.

备注:内容来源于stack exchange,提问作者khateeb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 15:40:36