Ubuntu – Install specific MongoDB in Ubuntu 16.04

mongodbUbuntu

Below installs 2.6.10 mongo version in Ubuntu

sudo apt-get install mongodb-server

I am looking to get the 2.6.13 version. How to fetch the exact version? Also how to prevent sudo apt-get update/upgrade from upgrading mongo to 3.x

Best Answer

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