doubledherin
doubledherin

Reputation: 360

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.

Upvotes: 20

Views: 45039

Answers (4)

Radian Jheng
Radian Jheng

Reputation: 698

  1. go to the guide page.

  2. switch the version you want at left side menu bar. enter image description here

  3. follow the guide of that version on page, then it's done.

Upvotes: 9

Liu Hao
Liu Hao

Reputation: 636

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'

Upvotes: 2

Ruslan Kurkebayev
Ruslan Kurkebayev

Reputation: 339

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

Upvotes: 24

BruceWayne
BruceWayne

Reputation: 3374

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/

Upvotes: 1

Related Questions