Search code examples
mongodbubuntuinstallation

E: Unable to locate package mongodb-org


I am trying to download mongodb and I am following the steps on this link.

But when I get to the step:

sudo apt-get install -y mongodb-org

I get the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mongodb-org  //This is the error

Why is this occurring and is there a work around?


Solution

  • I have faced the same issue but then fixed it by the changing the package file section command. The steps that I followed were:

    First try with this command:

    sudo apt-get install -y mongodb
    

    This is the unofficial mongodb package provided by Ubuntu and it is not maintained by MongoDB and conflicts with MongoDB’s officially supported packages.

    If the above command doesn't work then you can fix the issue by one of the following procedures:

    Step 1: Import the MongoDB public key

    In Ubuntu 18.*+, you may get invalid signatures. --recv value may need to be updated to EA312927.

    See here for more details on the invalid signature issue: MongoDB GPG - Invalid Signatures

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
    

    Step 2: Generate a file with the MongoDB repository url

    echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
    

    Step 3: Refresh the local database with the packages

    sudo apt-get update
    

    Step 4: Install the last stable MongoDB version and all the necessary packages on our system

    sudo apt-get install mongodb-org
    

    Or if the unofficial mongodb package provided by Ubuntu is not maintained by MongoDB and conflict with MongoDB’s officially supported packages. Use the official MongoDB mongodb-org packages, which are kept up-to-date with the most recent major and minor MongoDB releases.

    sudo apt-get install -y mongodb
    

    Hope this will work for you also. You can follow this MongoDB

    Update

    The above instruction will install mongodb 2.6 version, if you want to install latest version for Ubuntu 12.04 then just omit the above step 2 and follow below instruction instead of that:

    Step 2: Generate a file with the MongoDB repository url

    echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
    

    If you are using Ubuntu 14.04 then use bellow step instead of above step 2

    Step 2: Generate a file with the MongoDB repository url

    echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list