E: Unable to locate package mongodb-org - mongodb

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?

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

The true problem here may be if you have a 32-bit system. MongoDB 3.X was never made to be used on a 32-bit system, so the repostories for 32-bit is empty (hence why it is not found). Installing the default 2.X Ubuntu package might be your best bet with:
sudo apt-get install -y mongodb
Another workaround, if you nevertheless want to get the latest version of Mongo:
You can go to
https://www.mongodb.org/downloads
and use the drop-down to select "Linux 32-bit legacy"
But it comes with severe limitations...
This 32-bit legacy distribution does not include SSL encryption and is
limited to around 2GB of data. In general you should use the 64 bit
builds. See here for more information.

Try without '-org':
sudo apt-get install -y mongodb
Worked for me!

I'm running Ubuntu 14.04; and apt still couldn't find package; I tried all the answers above and more.
The URL that worked for me is this:
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
Source: http://www.liquidweb.com/kb/how-to-install-mongodb-on-ubuntu-14-04/

All steps are correct just change the Step 4 as below
Step 4: Install the last stable MongoDB version and all the necessary packages on our system
Command: sudo apt-get install mongodb
It has worked for me.

If you are currently using the MongoDB 3.3 Repository (as officially currently suggested by MongoDB website) you should take in consideration that the package name used for version 3.3 is:
mongodb-org-unstable
Then the proper installation command for this version will be:
sudo apt-get install -y mongodb-org-unstable
Considering this, I will rather suggest to use the current latest stable version (v3.2) until the v3.3 becomes stable, the commands to install it are listed below:
Download the v3.2 Repository key:
wget -qO - https://www.mongodb.org/static/pgp/server-3.2.asc | sudo apt-key add -
If you work with Ubuntu 12.04 or Mint 13 add the following repository:
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
If you work with Ubuntu 14.04 or Mint 17 add the following repository:
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
If you work with Ubuntu 16.04 or Mint 18 add the following repository:
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
Update the package list and install mongo:
sudo apt-get update
sudo apt-get install -y mongodb-org

The currently accepted answer works, but will install an outdated version of Mongo.
The Mongo documentation states that: MongoDB only provides packages for Ubuntu 12.04 LTS (Precise Pangolin) and 14.04 LTS (Trusty Tahr). However, These packages may work with other Ubuntu releases.
So, to get the lastest stable Mongo (3.0), use this (the different step is the second one):
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
apt-get update
apt-get install mongodb-org
Hope this helps.
I would like to add that as a previous step, you must check your GNU/Linux Distro Release, which will construct the Repo list url. For me, as I am using this:
DISTRIB_CODENAME=rafaela
DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela"
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
The original 2nd step:
"Create a list file for MongoDB": "echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list"
Didn't work as intended because it generated an incorrect Repo url. Basically, it put the distribution codename "rafaela" within the url repo which doesn't exist. You can check the Repo url at your package manager under Software Sources, Additional Repositories.
What I did was to browse the site:
http://repo.mongodb.org/apt/ubuntu/dists/
And I found out that for Ubuntu, "trusty" and "precise" are the only web folders available, not "rafaela".
Solution: Open as root the file 'mongodb-org-3.1.list' or 'mongodb.list' and replace "rafaela" or your release version for the corresponding version (for me it was: "trusty"), save the changes and continue with next steps. Also, your package manager can let you change easily the repo url as well.
Hope it works for you.! ---

You first need to add the package database and add the PGP key.
Run the following.
#add pgp key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
#add package file
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
#update package list
sudo apt-get update
#install mongo
sudo apt-get install -y mongodb-org

I had the same issue in 14.04, but I fixed it by these steps:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb- org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb
It worked like charm :)

sudo apt-get install -y mongodb
it works for 32-bit ubuntu, try it.best of luck.

This worked on Ubuntu 17.04
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
If you see a failure like:
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-tools_3.6.2_amd64.deb (--unpack):
trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.2.11-1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Then run this command:
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" |
sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
and
sudo apt update
sudo apt install mongodb-org
References:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

I had the same problems on Ubuntu 16.04 when I followed the steps posted on the official document.
Then I remove the text "[ arch=amd64,arm64 ]" in step2 and it works for me.
echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
apt-get install -y mongodb-org

Related

Version '100.2.1' for 'mongodb-org-tools' was not found

Background:
Quoting from the MongoDB Database Tools docs:
Starting with MongoDB 4.4, mongodump is now released separately from
the MongoDB Server and uses its own versioning, with an initial
version of 100.0.0. Previously, mongodump was released alongside the
MongoDB Server and used matching versioning.
Problem:
I'm trying to install the MongoDB Database Tools using Docker/Dockerfile:
...
RUN apt-get update
RUN apt-get install -y gnupg
RUN apt-get install -y wget
RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
RUN apt-get update
RUN apt-get install -y mongodb-org-tools=100.2.1
RUN echo "mongodb-org-tools hold" | dpkg --set-selections
...
But this line RUN apt-get install -y mongodb-org-tools=100.2.1 is giving me an error:
Version '100.2.1' for 'mongodb-org-tools' was not found
If I remove =100.2.1 the tools are installed.
But I need to specify this specific version (100.2.1) of the MongoDB Database Tools.
Question:
Is this possible? And how?
Seems to work by using:
RUN apt-get install -y mongodb-database-tools=100.2.1
Got the idea from this page:
https://docs.mongodb.com/database-tools/installation/installation-linux/
sudo dpkg -l mongodb-database-tools
sudo apt install ./mongodb-database-tools-*-100.2.1.deb
Can someone from MongoDB please confirm this is the proper way?

Hi, I'm trying to install mongodb on linux but got an error

I'm installing mognodb following step by step of the documentation https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ but getting an error at the step sudo apt-get install -y mongodb-org. Can't find any info to fix this problem.
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-shell but it is not going to be installed
Depends: mongodb-org-server but it is not going to be installed
Depends: mongodb-org-mongos but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Alos I've tried to install the dependencies one by one, but still getting the same error that points on other dependencies.
Import the public key used by the package management system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
Create a list file for MongoDB.
In Ubuntu 12.04 (deprecated):
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
In Ubuntu 14.04:
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
In Ubuntu 16.04:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
Reload local package database.
sudo apt-get update
It will throw a warning
W: http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/Release.gpg: Signature by key 492EAFE8CD016A07919F1D2B9ECBEC467F0CEB10 uses weak digest algorithm (SHA1)
Just Ignore It.
Install the MongoDB packages.
sudo apt-get install -y mongodb-org
After installation you can start MongoDB using
sudo service mongod start

how to install mongodb 3.2 version on ubuntu16.04

gaurav#mw:~$ sudo apt-get install mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mongodb-org is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'mongodb-org' has no installation candidate
1) step upgrade php version 7.0 to 7.2
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
2) step install mongo
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install mongodb-org
sudo service mongod start
sudo service mongod status
sudo systemctl enable mongod
3) step install php driver
sudo apt-get install php-mongodb
4) step create test.php file in /var/www/html and type code and save it
5) step restart your computer

Ubuntu 16.04 - MongoDB 3.4.x - Install specific version

i use the standard install guide for mongodb 3.4 on ubuntu 16.04:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install mongodb-org -y
This one installs me the latest version of mongodb 3.4.X
But what if i just want a specific version, lets say 3.4.9
Is there any way to just have this specific version installed?
Greetings and Thanks!
Instead of your last command you should input something like
sudo apt-get install -y mongodb-org=3.4.X mongodb-org-server=3.4.X mongodb-org-shell=3.4.X mongodb-org-mongos=3.4.X mongodb-org-tools=3.4.X

How to install a specific version of MongoDB?

I have yet to find a solution to the problem of installing a specific release of MongoDB. I've found several SO posts and other resources, to no avail. The official docs say:
sudo apt-get install -y mongodb-org=3.0.12 mongodb-org-server=3.0.12 mongodb-org-shell=3.0.12 mongodb-org-mongos=3.0.12 mongodb-org-tools=3.0.12
But I get error messages saying those versions are not found. I've tried previous versions as well, but I get the same error output.
Refer to Official mongodb administration 'Install on linux' documentation.
Example for Ubuntu
add repo list file
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
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
sudo apt-get update
Install mongo package
sudo apt-get install -y mongodb-org=3.0.12 mongodb-org-server=3.0.12 mongodb-org-shell=3.0.12 mongodb-org-mongos=3.0.12 mongodb-org-tools=3.0.12
Prevent upgrading mongodb version (optional)
Do it only if you don't want to accidentally upgrade mongo with apt-get
echo "mongodb-org hold" | sudo dpkg --set-selections &&
echo "mongodb-org-server hold" | sudo dpkg --set-selections &&
echo "mongodb-org-shell hold" | sudo dpkg --set-selections &&
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections &&
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
go to the guide page.
switch the version you want at left side menu bar.
follow the guide of that version on page, then it's done.
Before installing, you have to update the list files (repos). Check below link for more
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Well, I think it's not recommend to install previous version package by package manager like apt or yum, which may break package dependency relation.
MongoDB legacy version (tgz package for all linux distributions) can be a good choice.
All legacy history package can be found here:
https://www.mongodb.org/dl/linux/x86_64
You can install some legacy version by:
wget -c "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-A.B.C.tgz"
just replace A.B.C with the version you want to install.
unpack it:
tar -zxvf mongodb-linux-x86_64-A.B.C.tgz
run mongodb server:
'./mongodb-linux-x86_64-A.B.C/bin/mongod'