Skip to main content

MongoDB Up & Running

MongoDB Up & Running


What is mongoDB ?

            Mongo DB has rapidly grown to become a popular database for web applications and is a perfect fit for Node.JS applications, letting you write Javascript for the client, backend and database layer. Its schemaless nature is a better match to our constantly evolving data structures in web applications, and the integrated support for location queries is a bonus that’s hard to ignore. Throw in Replica Sets for scaling, and we’re looking at really nice platform to grow your storage needs now and in the future. MongoDB is an open source database that uses a document-oriented data model.MongoDB is one of several database types to arise in the mid-2000s under the NoSQL banner. Instead of using tables and rows as in relational databases, MongoDB is built on an architecture of collections and documents. Documents comprise sets of key-value pairs and are the basic unit of data in MongoDB. Collections contain sets of documents and function as the equivalent of relational database tables. 

Why MongoDB differs from other NoSQL Databases ?

                Just like most of the NoSQL databases, MongoDB supports dynamic design schema, allowing collections to store documents in different fields and structures. MongoDB uses a format called BSON ( Binary JSON ( JavaScript Object Notation ) ). The ability of horizontal scaling is derived from sharding. It enables data collections to be distributed among multiple systems.

How to Setup a MongoDB Database ?


·         WINDOWS PLATFORMS

1.       First download the MongoDB package depending on the architecture of the PC by visiting this link.
2.       Once you have downloaded the installer, in windows explorer locate the downloaded MongoDB.msi.
Double click it and run the installer, it will guide you the process.
3.       Once you have successfully installed MongoDB, you should setup the environment for MongoDB to operate. For that you should create a /data/db in the MongoDB installation directory to allow MongoDB to store the data.
You can specify an alternate path for data files using the --dbpath option to mongod.exe, 
As an Example
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath d:\test\mongodb\data”
Above command will make the required folders automatically.
You can Optionally set the path in configuration path. If you need assistance on that please refer the docs .
4.       After you completing the above configurations you are ready to start the MongoDB server for the first time.
For that run this command in CMD
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe”
5.       Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features”. But you are okay to ignore them all.
6.       Now to connect to MongoDB, while the previous CMD is running open up another CMD and run the same command.
The reason is you are running the process mongod in the first CMD. So we need anther CMD to access the real Database.
7.       Enjoy MongoDB !

·         ON MAC OS X


1.       Open up Terminal and run this command.
“curl -O https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.4.2.tgz
2.       Once your download is complete, run this command.
“tar -zxvf mongodb-osx-x86_64-3.4.2.tgz.
3.       Then once you have unzipped the mongoDB package, run this command
“mkdir -p mongodb”
“cp -R -n mongodb-osx-x86_64-3.4.2/ mongodb”
4.       Then you will need to create the directory for the MongoDB to store to store data. For that we need to run this command
“mkdir -p /data/db”
5.       Finally just RUN mongod by running this command
“mongod”
6.       Enjoy MongoDB.


Now such a DB is not good enough with an CLI because it’s hard to view and manipulate the data on it. A GUI is definitely need.

Try MongoDB Compass. Download it from here.

Comments

Popular posts from this blog

An Introduction to Spring Framework

An Introduction to Spring Framework   What is Spring ? Spring is an application framework . Unlike single-tier frameworks such as Struts or Hibernate, Spring aims to help structure whole applications in a consistent, productive manner, pulling together best-of-breed single-tier frameworks to create a coherent architecture. Why Spring ? The Spring Framework is an open source application framework that aims to make J2EE development easier. We’ll look at the motivation for Spring, its goals, and how Spring can help you develop high-quality applications quickly. Using J2EE “out of the box” is not an attractive option. Many J2EE APIs and services are cumbersome to use. J2EE does a great job of standardizing low-level infrastructure, solving such problems as how can Java code access transaction management without dealing with the details of transactions. But J2EE does not provide an easily usable view for application code.That is the role of an application framework, such a

Apache Maven

Introduction to Apache Maven   What is maven? Maven is a project management tool which encompasses a project object model, a set of standards, a project life cycle, a dependency management system, and logic for executing plugin goals at defined phases in a life cycle. When you use Maven, you describe your project using a well-defined project object model, Maven can then apply cross-cutting logic from a set of shared (or custom) plugins. The great majority of Maven users are going to call Maven a “build tool”: a tool used to build deployable artifacts from source code. Build engineers and project managers might refer to Maven as something more comprehensive: a project management tool. What is the difference? A build tool such as Ant is focused solely on preprocessing, compilation, packaging, testing, and distribution. A project management tool such as Maven provides a super set of features found in a build tool. In addition to providing build capabilities, Maven can also ru

Tour Management System - 2nd year ITP project

   Introduction to the System  The Lotus Tours Company which is located in Nugegoda, provides a good service to the customers who wish to visit sacred places in India and Thailand. India and Thailand are some beautiful countries in Asia. A trip to these countries can reveal numerous mystic things regarding its culture, art tradition history etc. Any person who wish to travel through the Lotus Company are allowed. Even the customers who doesn’t have a passport can reserve a date and get registered. Company will get all the details from the customer who doesn’t have a passport and help to prepare a new passport for them They have many packages in different prices. To get registered every customer should deposit Rs. 10,000 in advance. Then the rest of the amount are paid in installments prior to the tour date or the full amount for the tour can be paid at once. When a customer make a reservation, all the reservation details are recorded in a file and unique ID number is given to