16

I am not able to install MongoDB on Ubuntu 22.04. I am following the official documentation for the installation.

This is the output I am getting after following the installation instructions:

this is the output I am getting after following the official documentation

https://repo.mongodb.org/apt/ubuntu/focal/mongodb-org/5.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.
karel
  • 122,292
  • 133
  • 301
  • 332

7 Answers7

15

The below solution worked for me to install mongodb:

  1. Download libssl1.1_1.1.1f-1ubuntu2_amd64.deb:

    wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
    
  2. Install it using the dpkg command:

    sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
    
  3. Then install mongodb-org-server_6.0.0_amd64.deb downloaded from https://www.mongodb.com/.

Instructions used from this link to install libssl1.1 in Ubuntu 22.04 LTS.

3

The commands your're using do not work on Ubuntu Jammy(22.04 LTS), those are only suitable for Ubuntu Focal(20.04 LTS). The Mongodb team is still working on the support for Ubuntu Jammy(x86), you can follow the status of this issue on https://jira.mongodb.org/browse/SERVER-62300

2

If you're only interested in the client (mongosh), it is available for 22.04 on the mongo repo, without having to install libssl1.1:

# download the GPG key (avoids the deprecation warning with apt-key)
wget https://www.mongodb.org/static/pgp/server-6.0.asc
gpg --no-default-keyring --keyring ./temp-keyring.gpg --import server-6.0.asc
gpg --no-default-keyring --keyring ./temp-keyring.gpg --export --output mongo-server-6.0.gpg
sudo mv mongo-server-6.0.gpg /etc/apt/keyrings/

add the mongo repository, trusting the GPG key

echo "deb [signed-by=/etc/apt/keyrings/mongo-server-6.0.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

install mongo

sudo apt update sudo apt install mongodb-mongosh

delete the files

rm temp-keyring.gpg* server-6.0.asc*

Based on https://askubuntu.com/a/1307181/918106 to avoid a warning with apt-key.

1

You get this error because libssl1.1 was removed from Ubuntu 22.04 in favor of libssl3. A quick fix until MongoDB officially supports 22.04 is running the following commands:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.16_amd64.deb
sudo apt-get update
dpkg -i libssl1.1_1.1.1f-1ubuntu2.16_amd64.deb

Worked for me :)

1

Finally mongodb repositories has packages for Ubuntu 22. You can use this line in any of apt files under /etc/apt/source.list.d

deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse

And install. I am not sure if it is officially released yet, but seems to work find on my jammy instance.

Gadi
  • 46
0

It is because of the missing dependencies that mongodb does not getting installed on Ubuntu 22.04. The main reason is that the dependency of libssl1.1 is missing. So we need to install it separately.

  1. Install some required packages:

    sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common
    
  2. Run:

    echo "deb http://security.ubuntu.com/ubuntu impish-security main" | sudo tee /etc/apt/sources.list.d/impish-security.list
    
  3. Go to a root shell:

    sudo -i
    

    and run this:

    wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
    
  4. Update the package lists:

    apt update
    
  5. Install libssl1.1:

    apt install libssl1.1
    
  6. Run:

    wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
    
  7. Run:

    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
    
  8. Update the package lists:

    apt update
    
  9. Install mongodb-org:

    apt install -y mongodb-org
    

    The latest version of mongodb will be installed.

    To start it run:

     systemctl enable mongodb
     systemctl start mongodb
    
  10. In case MongoDB doesn’t start run the command below to reload.

    systemctl daemon-reload
    
  11. Finally exit the root shell by running:

    exit
    
0

Install MongoDB in Ubuntu 22.04 LTS using this simple command

Import the public key used by the package management system.

wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -

The operation should respond with an OK.

However, if you receive an error indicating that gnupg is not installed, you can:

Install gnupg and its required libraries using the following command:

sudo apt-get install gnupg

Once installed, retry importing the key:

wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -

Create a list file for MongoDB

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

Reload local package database and install MongoDB sudo apt-get update sudo apt-get install -y mongodb-org

sudo systemctl start mongod.service

If you receive an error similar to the following when starting mongod:

Failed to start mongod.service: Unit mongod.service not found.

Run the following command first:

sudo systemctl daemon-reload

sudo systemctl status mongod

sudo systemctl enable mongod.service

sudo systemctl restart mongod.service

Check it's running or not

mongosh