Installing MongoDB

If you use Windows or Linux, make sure to download either the
32-bit or 64-bit version according to your system architecture.Mac users are safe to
download the 64-bit version.

So first you have to go to https://www.mongodb.com/download-center#community
here you can find and download the MongoDB as per your OS or if you are on linux you can try Install MongoDB Community Edition on Ubuntu
Installing MongoDB from binaries
You can download the right version of MongoDB using the download page at
http://www.mongodb.org/downloads . Alternatively, you can do this via CURL by
executing the following command:
$ curl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.4.tgz
Notice that we have downloaded the Mac OS X 64-bit version, so make sure you alter
the command to fit the version suitable for your machine. After the downloading
process is over, unpack the file by issuing the following command in your command-
line tool:
$ tar -zxvf mongodb-osx-x86_64-2.6.4.tgz
Now, change the name of the extracted folder to a simpler folder name by running
the following command:
$ mv mongodb-osx-x86_64-2.6.4 mongodb
MongoDB uses a default folder to store its files. On Linux and Mac OS X, the default
location is /data/db , so in your command-line tool run the following command:
$ mkdir -p /data/db

The preceding command will create the data and db folders because the –p flag
creates parent folders as well. Notice that the default folder is located outside of
your home folder, so do make sure you set the folder permission by running the
following command:
$ chown -R $USER /data/db
Now that you have everything prepared, use your command-line tool and go to the
bin folder to run the mongod service as follows:
$ cd mongodb/bin
$ mongod

Install MongoDB using a package manager
Sometimes the easiest way to install MongoDB is by using a package manager. The
downside is that some package managers are falling behind in supporting the latest
version. Luckily, the team behind MongoDB also maintains the official packages
for RedHat, Debian, and Ubuntu, as well as a Hombrew package for Mac OS X.
Note that you’ll have to configure your package manager repository to include the
MongoDB servers to download the official packages.
To install MongoDB on Red Hat Enterprise, CentOS, or Fedora using Yum, follow
the instructions at http://docs.mongodb.org/manual/tutorial/install-
mongodb-on-red-hat-centos-or-fedora-linux/ .
To install MongoDB on Ubuntu using APT, follow the instructions at
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ .
To install MongoDB on Debian using APT, follow the instructions at
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/ .
To install MongoDB on Mac OS X using Homebrew, follow the instructions at
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ .

Start MongoDB.
sudo service mongod start

Verify that MongoDB has started successfully
Verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading
[initandlisten] waiting for connections on port

Stop MongoDB.
sudo service mongod stop

Restart MongoDB
sudo service mongod restart

One thought on “Installing MongoDB

  1. Pingback: Inserting first Value in MongoDB | Abhinav Bhardwaj

Leave a comment