Installing MongoDB on Ubuntu Linux 14.04 (Trusty)

MongoDB is an open source, document-oriented database designed with both scalability and developer agility in mind. Instead of storing your data in tables and rows as you would with a relational database, in MongoDB you store JSON-like documents with dynamic schemas.

You can watch this video below for more information:

Basically MongoDB is a non-relational datastore for JSON documents. The documents are stored in a collection.
A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. There are some characteristics like:

schemaless – MongoDB has a dynamic schema which means that 2 (two) documents for example, doesn’t need to have the same schema.

don’t support JOINS

don’t have TRANSACTIONS across multiple documents/collections like a relational database.

and so on…

Now that I’ve introduced you to MongoDB I will show you how to install it on a Linux box.

First thing you have to do of course is to download the latest stable version of MongoDB:

Extract the files from the archive you just downloaded:

Copy the extracted archive to the target directory which means the location from which MongoDB will run:

In my case I just renamed the mongodb-linux-x86_64-ubuntu1410-clang-3.0.7 directory to /mongodb.

add the following line to your shell’s rc file (e.g. ~/.bashrc):

Replace mongodb-install-directory with the path to the extracted MongoDB archive.

Reload you bashrc configuration by typing the command:

Before you start MongoDB for the first time, you have to create the directory in which the mongod process will write data. By default, the mongod process uses the /data/db directory. If you create a directory other than this one, you must specify that directory in the dbpath option when starting the mongod process.

I just created the default directory suggested by MongoDB:

And then I changed the ownership from root to my username…

…because you have to ensure that the user account running **mongod** has read and write permissions for the directory.

Now run the mongod process:

If you see this line above in your shell…

…Congratulations!!! You have just installed MongoDB on Ubuntu Linux 14.04.

See you next time.

Source: MongoDB official website – Installing MongoDB on Linux