How to install mongodb

In this article you will learn how to install mongo under Linux / UNIX environments.

Note: When this article was written (May 2013) we are using Debian based operating system Ubuntu 12.04 LTS. This works under Ubuntu 10.04 LTS, Ubuntu 13, CentOS / RHEL / Redhat Enterprise Linux, Debian 6 and Debian 7.

What is MongoDB?

MongoDB is a document database server that provides high performance, high availability, and scalability for web applications.

It has features like embedding which makes reads and writes fast. Indexes can include keys from embedded documents. Arrays and features like high availability also help replicate servers with automatic master failover.

MongoDB is used in many production application environments and it is commonly used by modern web applications.

In this article we will cover installation of MongoDB server installation by using documentation and references provided by the MongoDB docs itself and with the help of the bash script we will create to install MongoDB easily.

Following the commands below, you either need to run commands as root and ignore sudo. Or if you are logged in with your user it should be a sudo user.

sudo apt-get update

sudo apt-get -y upgrade

The first command is updating software update repositories. The second command is upgrading software packages installed against the updated repositories.

Now install MongoDB server by creating a bash script, we name the bash script as “install_mongodb.sh”: