Install MongoDB

Via apt-get
Full Script:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
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
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
sudo service mongod status
Explain:
  • MongoDB requires a repository Key to be installed. so we bring it.
  • we need to add MongoDb repository details on our machine .. Don't ask why .. just add it.
  • update apt-get repositories
  • start install
  • start MongoDB
  • check whether it's run or not
Prevent Upgrade
Sometimes you need to prevent apt-get from upgrading specific package and hold it on current version.
run the following commands will achieve this goal.
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


Back To List