How to install or upgrade MongoDB on Ubuntu

By | December 29, 2015

Step 1: Add Mongodb to your sources.list.d (for Ubuntu 14.04)

This allows you to get the latest files from when you run sudo apt-get install

echo "deb trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Step 2: Reload the local package database

sudo apt-get update

Step 3: Install MongoDB

sudo apt-get install -y mongodb-org

-y automatically selects “yes” for any options that appears.

That is all there is to it.

To install a specific release you need to specify each component package individually along with the version number. eg

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

How to find out what version of MongoDB you are using?

Easy! Just log into MongoDB or run db.version()

image2015-12-15 11-44-18

How to upgrade to the latest MongoDB version?

Step 1: Download the latest version


curl -O

Step 2: Extract the file.

tar -zxvf mongodb-linux-x86_64-3.2.0.tgz

Step 3: Stop the current MongoDB daemon

sudo service mongod stop

Step 4: Copy the binary files to /usr/bin

sudo cp * /usr/bin

Assuming you are in the /bin folder of the extracted tar

Step 5: Restart MongoDB

sudo service mongod restart

One thought on “How to install or upgrade MongoDB on Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *