Install specific MongoDB in Ubuntu 16.04

Solution 1:

MongoDB 2.6 reached end of life at the end of October, 2016. The final release version was 2.6.12 (so there will be no 2.6.13).

To install a specific release you can specify the desired version, eg:

sudo apt-get install -y mongodb-org=2.6.12 mongodb-org-server=2.6.12 mongodb-org-shell=2.6.12 mongodb-org-mongos=2.6.12 mongodb-org-tools=2.6.12

You can also pin a specific version of MongoDB to prevent unintended upgrades.

For each installed package you want to pin, use a command line similar to:

echo "mongodb-org hold" | sudo dpkg --set-selections