Question

install & uninstall mongodb in ubuntu

(pygenie) root@zijinliushui-dekt:/www# sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease                                                  
Ign:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease                              
Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease                                          
Ign:4 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 InRelease                               
Hit:5 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease                            
Hit:6 http://archive.ubuntu.com/ubuntu jammy-backports InRelease                                        
Get:7 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release [2989 B] 
Hit:8 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 Release
Get:10 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release.gpg [801 B]
Ign:10 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release.gpg
Hit:11 http://security.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done                          
W: https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: https://repo.mongodb.org/apt/ubuntu/dists/bionic/mongodb-org/4.0/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: GPG error: https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release: The following signatures were invalid: EXPKEYSIG 68818C72E52529D4 MongoDB 4.0 Release Signing Key <packaging@mongodb.com>
E: The repository 'https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 25, 2024

Hi,

It is important that you first import the public GPG key for the latest stable version of MongoDB by running the following command. If you intend to use a version of MongoDB other than 4.4, be sure to change 4.4 in the URL portion of this command to align with the version you want to install:

curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

In the above example, cURL prints the content of the GPG key file and then pipes it into the following sudo apt-key add - command, thereby adding the GPG key to your list of trusted keys.

You can follow all of those steps here:

https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-20-04

If this still does not work, feel free to share more information about your exact setup, for example, what OS you are using, whether you follow any tutorials, etc.

An alternative option here is to also consider using a Managed MongoDB cluster instead of managing your own instance:

https://www.digitalocean.com/products/managed-databases-mongodb

That way you will not have to worry about managing your own instance and will get many benefits out of the box like:

  • Free daily backups
  • Automatic updates
  • Access latest releases
  • High availability
  • Easy scalability
  • End-to-end security

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.