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
  • 114,770
  • 2
    Please copy/paste and format text instead of pictures of text. A picture (of text) can't be read on a text-only terminal, can't be copied from (edited, tried, and made to work), AND makes one take an action to even read your Question. Since we're all volunteers, some won't click. Please read https://askubuntu.com/help/formatting – waltinator Apr 12 '22 at 20:44
  • 1
    Telling us which remote procedure (RP) you "followed" doesn't help us help you for N reasons: 1) It's remote. Will the link exist tomorrow? 2) Reading the RP doesn't tell us how accurately you "followed" it. Did you suffer typos or missed lines? We have. 3) Reading the RP omits the error messages you got on your system. These error messages (and the commands that caused them) are key elements in any diagnosis. – waltinator Apr 12 '22 at 20:45
  • 1
    Ubuntu 22.04 doesn't yet exist; it's currently the development release Ubuntu jammy and remains that until it reaches RC state which isn't expected until after 14 April 2022, and isn't on-topic here until release on 21 April 2022. https://discourse.ubuntu.com/t/jammy-jellyfish-release-schedule/23906 Please refer https://askubuntu.com/help/on-topic. For support issues with Ubuntu jammy you'll need to use a #ubuntu-next or #ubuntu+1 site (IRC, UF etc) – guiverc Apr 12 '22 at 21:18
  • If you wish to report bugs, firstly thank you for helping test the release, but please see https://help.ubuntu.com/community/ReportingBugs and use a #ubuntu+1 site such as IRC, https://ubuntuforums.org/ etc. This site isn't tracked for ubuntu+1 or #ubuntu-next issues – guiverc Apr 12 '22 at 21:18
  • 1
    Your apt update output shows mixed focal and jammy sources. Looks like you added wrong-version focal mongodb sources to a jammy system. Consult mongodb upstream for jammy install instructions. Since 22.04 hasn't been released yet, those instructions might not be published yet. – user535733 Apr 13 '22 at 04:24
  • how about i install MongoDB in Ubuntu 20.04 and then upgrade to Ubuntu 22.04, will it work? – Mihir Panchal Apr 14 '22 at 03:14
  • You'll more likely find the focal packages will not be available for jammy which will prevent a release-upgrade from occurring unless you remove those 3rd party packages first, which puts you back where you are here. Ubuntu jammy is still in beta testing being an unreleased product intended for testing only, so problems are discovered, reported & issues can be fixed in the remaining time before release. – guiverc Apr 14 '22 at 03:18

7 Answers7

14

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

Luan Lima
  • 131
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 :)

  • It's not a duplicate. His solution doesn't work because the link he has is broken. It used to work but not anymore. It also doesn't work for mongodb 6.00 because the version of libssl1.1 he's using isn't recognized by the 6.0 installation. I just tried it like 30 minutes ago and I can't comment on his post because my reputation is low @karel – Amr Shawki Aug 04 '22 at 13:34
  • your solution worked for me, but all over the internet I read that this is not the safe way to do it. Does this trick have any potentially vulnerable side effect? – Radheya Aug 04 '22 at 17:49
  • 3
    @Dhruvify I really don't know. In general, TLS 1.1 is deprecated as it has many security vulnerabilities which is probably why Ubuntu migrated to TLS 3.0 which is secure. I assume by re installing TLS 1.1, you open yourself up to those vulnerabilities? Not sure if that is why they say it's insecure or not though but for now, you can't run MongoDB without doing this until it officially supports 22.04 – Amr Shawki Aug 05 '22 at 05:12
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
  • 36
  • 4
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
Rakibulinux
  • 101
  • 1