Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • Software and Tools
    • School Learning
    • Practice Coding Problems
  • Go Premium
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
How to Connect Node to a MongoDB Database ?
Next article icon

Create Database using MongoDB Compass

Last Updated : 27 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

MongoDB is a popular NoSQL database that uses a document-oriented storage model, differing from traditional relational databases. Instead of storing data in tables with rows and columns, MongoDB stores data as documents in BSON format. MongoDB Compass is a graphical user interface (GUI) that allows users to interact with MongoDB databases easily, without requiring advanced knowledge of MongoDB query syntax.

In this article, We will learn about the process of creating a MongoDB database using MongoDB Compass, from installation to managing our first database. By the end, we'll be able to create databases and collections and insert documents into MongoDB with ease.

What is MongoDB Compass?

MongoDB Compass is a free, powerful GUI for MongoDB. It simplifies managing your MongoDB data by providing an intuitive interface to interact with our database. Using MongoDB Compass, we can create, query, update, and delete documents without the need for complex MongoDB commands. It's particularly useful for those who prefer working with a graphical interface instead of writing queries manually.

Understanding MongoDB Document-Oriented Storage vs Traditional Relational Databases

  • MongoDB is a database that utilizes a document-oriented approach to store data. It internally stores data in BSON format but as developers, we can interact with MongoDB using JSON to send and receive data.
  • MongoDB handles the conversion between JSON and BSON automatically. In contrast, traditional relational databases like MySQL store data in tables. Each table represents a real-life entity and within a table, multiple rows correspond to individual data records. The columns in a table represent the properties of the entity.
  • In MongoDB, data is stored in the form of documents, which are similar to JSON objects. Collections in MongoDB serve the purpose of tables in relational databases. Essentially, collections are groups of JSON-like documents.
  • Each record in a collection is referred to as a document, which can be seen as the equivalent of a row in a relational database.
  • A document in MongoDB is essentially a JSON object (internally stored as BSON) that contains multiple key-value pairs.
  • Each key within the JSON represents a property of the entity. Thus in MongoDB the key in a key-value pair can be considered equivalent to a column in a relational database.

Example of a Document

The Document contains the information of a STUDENT in JSON format.

{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "CS"
}

Example of a Collection

The Bunch of documents creates a collection.

[
{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "CS"
},
{
"Name" : "Vivek",
"Age" : 19,
"Gender" : "Male",
"Dept" : "BBA"
},
{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "HIS"
},
{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "CS"
}
]

How to install MongoDB Compass

MongoDB Compass is a GUI interface for MongoDB. It allows users to analyze the content of their stored data without any prior knowledge of MongoDB query syntax. For Create Database using MongoDB Compass. First of all, Need to Install MongoDB Compass Application on the system.

Steps for Install MongoDB Compass

Step 1: Download the MongoDB Compass exe package from MongoDB official Website.

Step 2: After Redirect to that page Click on "Download" Button.

9.png

Step 3: After Successful Download, Open the downloaded file by double click on Downloaded File.

Step 4: After Double Click on the Downloaded File. MongoDB Compass Start Installing in your system. It takes a few seconds to install.

10.png

Step 5: After Successful Install it will be automatically opened in your system.

11.png

From the Above Steps, we have learned how to Install MongoDB Compass. Now Lets, Learn How to Create a Database using MongoDB Compass.

Steps to Create a Database Using MongoDB Database

Now that MongoDB Compass is installed, follow these steps to create your first database and collection:

Step 1: Simply Open MongoDB Compass on your system.

Step 2: After Successfully Opening, click the Connect button to connect to your MongoDB server.

Step 3: If you're using MongoDB Atlas, copy the connection string from the Atlas dashboard and paste it into the Compass connection field. If we're working with a local MongoDB instance, use the default connection URI: mongodb://localhost:27017.

1.png

Step 4: After connecting to MongoDB, click the plus (+) sign next to Databases on the left sidebar.

2.png

Step 5: After Clicking on Plus (+) icon, a popup will appear in which you have to give Database Name and Collection Name.

3.png

Step 6: Here we can give any Database Name and Collection Name as per your Choice. Here taking the Database name "GFG" and Collection Name "college".

Step 7: After that Click on the "Create Database" Button.

4.png

From the above Steps Database of the name "GFG" will be Created.

Step 8: After that, click on "ADD DATA" and select the "Insert document" option.

5.png

Step 9: After Clicking on "Insert document" a new popup appear.

6.png

Step 10: Here paste or write the bunch of documents that is Collection and After after that Click on the "Insert" Button.

Database have been created using MongoDB compass.

Conclusion

Overall, MongoDB's document-oriented storage offers a flexible and scalable alternative to traditional relational databases. By using JSON-like documents and collections, MongoDB simplifies the management of complex data structures and offers automatic conversion between JSON and BSON. Tools like MongoDB Compass further enhance user experience by providing a graphical interface for managing and interacting with MongoDB databases.


Next Article
How to Connect Node to a MongoDB Database ?

R

rohitdotcom
Improve
Article Tags :
  • MongoDB
  • NodeJS-Questions

Similar Reads

    MongoDB - Create Database using Mongo Shell
    MongoDB is a popular NoSQL database that uses collections and documents, which are highly flexible and scalable. Unlike relational databases (RDBMS), MongoDB does not use tables and rows but stores data in a more dynamic, JSON-like format. In this article, we'll explore how to create a MongoDB datab
    4 min read
    MongoDB - Create Database using Mongo Shell
    MongoDB is a popular NoSQL database that uses collections and documents, which are highly flexible and scalable. Unlike relational databases (RDBMS), MongoDB does not use tables and rows but stores data in a more dynamic, JSON-like format. In this article, we'll explore how to create a MongoDB datab
    4 min read
    How to create new Mongodb database using Node.js ?
    mongodb module: This Module is used to performing CRUD(Create Read Update Read) Operations in MongoDb using Node.js. We cannot make a database only. We have to make a new Collection to see the database. The connect() method is used for connecting the MongoDb server with the Node.js project. Please r
    1 min read
    How to Create Database and Collection in MongoDB
    MongoDB is a widely used NoSQL database renowned for its flexibility, scalability, and performance in managing large volumes of unstructured data. Whether you’re building a small application or handling big data, MongoDB offers an easy-to-use structure for managing your data. In this article, we wil
    6 min read
    How to Connect Node to a MongoDB Database ?
    Connecting Node.js to MongoDB is a common task for backend developers working with NoSQL databases. MongoDB is a powerful, flexible, and scalable database that stores data in a JSON-like format. In this step-by-step guide, we'll walk through the entire process from setting up your development enviro
    6 min read
    Install MongoDB Compass on Windows
    MongoDB Compass is a powerful graphical user interface for MongoDB which is designed to simplify database management. It offers features like easy querying, index visualization and an aggregation pipeline builder. Compass offers tools for schema analysis and structure validation, making it valuable
    5 min read
`; $(commentSectionTemplate).insertBefore(".article--recommended"); } loadComments(); }); }); function loadComments() { if ($("iframe[id*='discuss-iframe']").length top_of_element && top_of_screen articleRecommendedTop && top_of_screen articleRecommendedBottom)) { if (!isfollowingApiCall) { isfollowingApiCall = true; setTimeout(function(){ if (loginData && loginData.isLoggedIn) { if (loginData.userName !== $('#followAuthor').val()) { is_following(); } else { $('.profileCard-profile-picture').css('background-color', '#E7E7E7'); } } else { $('.follow-btn').removeClass('hideIt'); } }, 3000); } } }); } $(".accordion-header").click(function() { var arrowIcon = $(this).find('.bottom-arrow-icon'); arrowIcon.toggleClass('rotate180'); }); }); window.isReportArticle = false; function report_article(){ if (!loginData || !loginData.isLoggedIn) { const loginModalButton = $('.login-modal-btn') if (loginModalButton.length) { loginModalButton.click(); } return; } if(!window.isReportArticle){ //to add loader $('.report-loader').addClass('spinner'); jQuery('#report_modal_content').load(gfgSiteUrl+'wp-content/themes/iconic-one/report-modal.php', { PRACTICE_API_URL: practiceAPIURL, PRACTICE_URL:practiceURL },function(responseTxt, statusTxt, xhr){ if(statusTxt == "error"){ alert("Error: " + xhr.status + ": " + xhr.statusText); } }); }else{ window.scrollTo({ top: 0, behavior: 'smooth' }); $("#report_modal_content").show(); } } function closeShareModal() { const shareOption = document.querySelector('[data-gfg-action="share-article"]'); shareOption.classList.remove("hover_share_menu"); let shareModal = document.querySelector(".hover__share-modal-container"); shareModal && shareModal.remove(); } function openShareModal() { closeShareModal(); // Remove existing modal if any let shareModal = document.querySelector(".three_dot_dropdown_share"); shareModal.appendChild(Object.assign(document.createElement("div"), { className: "hover__share-modal-container" })); document.querySelector(".hover__share-modal-container").append( Object.assign(document.createElement('div'), { className: "share__modal" }), ); document.querySelector(".share__modal").append(Object.assign(document.createElement('h1'), { className: "share__modal-heading" }, { textContent: "Share to" })); const socialOptions = ["LinkedIn", "WhatsApp","Twitter", "Copy Link"]; socialOptions.forEach((socialOption) => { const socialContainer = Object.assign(document.createElement('div'), { className: "social__container" }); const icon = Object.assign(document.createElement("div"), { className: `share__icon share__${socialOption.split(" ").join("")}-icon` }); const socialText = Object.assign(document.createElement("span"), { className: "share__option-text" }, { textContent: `${socialOption}` }); const shareLink = (socialOption === "Copy Link") ? Object.assign(document.createElement('div'), { role: "button", className: "link-container CopyLink" }) : Object.assign(document.createElement('a'), { className: "link-container" }); if (socialOption === "LinkedIn") { shareLink.setAttribute('href', `https://www.linkedin.com/sharing/share-offsite/?url=${window.location.href}`); shareLink.setAttribute('target', '_blank'); } if (socialOption === "WhatsApp") { shareLink.setAttribute('href', `https://api.whatsapp.com/send?text=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } if (socialOption === "Twitter") { shareLink.setAttribute('href', `https://twitter.com/intent/tweet?url=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } shareLink.append(icon, socialText); socialContainer.append(shareLink); document.querySelector(".share__modal").appendChild(socialContainer); //adding copy url functionality if(socialOption === "Copy Link") { shareLink.addEventListener("click", function() { var tempInput = document.createElement("input"); tempInput.value = window.location.href; document.body.appendChild(tempInput); tempInput.select(); tempInput.setSelectionRange(0, 99999); // For mobile devices document.execCommand('copy'); document.body.removeChild(tempInput); this.querySelector(".share__option-text").textContent = "Copied" }) } }); // document.querySelector(".hover__share-modal-container").addEventListener("mouseover", () => document.querySelector('[data-gfg-action="share-article"]').classList.add("hover_share_menu")); } function toggleLikeElementVisibility(selector, show) { document.querySelector(`.${selector}`).style.display = show ? "block" : "none"; } function closeKebabMenu(){ document.getElementById("myDropdown").classList.toggle("show"); }
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences