Installing MongoDB

By @rhotimee1/11/2018utopian-io

This is a simple tutorial on how to Install MongoDB on your PC.

image.png

About MongoDB
MongoDB (from humongous) is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas. MongoDB is developed by MongoDB Inc. and is published under a combination of the GNU Affero General Public License and the Apache License.
source: wikipedia

Tutorial:

  1. Download MongoDB.
    Download
    Select the Community Server and specify your Operating System (Windows, Linux, OSX, Solaris) to download.

  2. Extract the folder, rename it to mongo and move it to your user directory.
    Screen Shot 2018-01-11 at 2.25.37 PM.png

  3. Create a new Directory in your user directory alongside mongo called mongo-data. This is for storing the actual data that is inside the database.

  4. Using your terminal, cd to the bin in the mongo directory and enter this command below. This is to start up the server.

./mongod --dbpath ~/mongo-data

you should see something like this (below)

Screen Shot 2018-01-11 at 2.49.28 PM.png

  1. Now, lets test if the installation is working. Open another tab on your terminal (CMD T), the bin directory would still be there. Then enter $ ./mongo . We should see something like the screenshot below.

Screen Shot 2018-01-11 at 2.55.29 PM.png

With this , we can now type in some commands.
first, lets insert some text.

> db.Todo.insert({text: 'learn mongodb'})

This inserts learn mongodb to the database.
Result:

Screen Shot 2018-01-11 at 3.00.22 PM.png

lets list our todo. use the command below.

> db.Todo.find()

Result:
Screen Shot 2018-01-11 at 3.00.58 PM.png

If all these commands work perfectly, your MongoDB was correctly installed.



Posted on Utopian.io - Rewarding Open Source Contributors

3

comments