paint-brush
How to Connect MongoDB(4.2.10) and MongoDB Compass Locallyby@mccauley
250 reads

How to Connect MongoDB(4.2.10) and MongoDB Compass Locally

by Macaulay UzuNovember 22nd, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

MongoDB is a document-oriented database program that uses JSON-like documents with optional schemas. It is classified as a No.SQL database program. The MongoDB Compass is just a GUI for MongoDB. It's just a tool for installing MongoDB on your Machine. It can be downloaded from the Official MongoDB website or downloaded from version 4.2.10. It's a free version of the MongoDB database. It will be used to run MongoDB's Compass database.
featured image - How to Connect MongoDB(4.2.10) and MongoDB Compass Locally
Macaulay Uzu HackerNoon profile picture

What is MongoDB?

MongoDB is a document-oriented database program.

It is classified as a NoSQL database program that uses JSON-like documents with optional schemas.

What is MongoDB Compass?

MongoDB Compass is just a GUI for MongoDB

Installing MongoDB on your Machine

  • In the version tab, select version 4.2.10
  • Select your appropriate Operating system in the platform tab
  • And the Most important part here, the Package Tab. Make sure you select the ZIP option, and download

    --Important Steps

    • After downloading the zipped folder, Extract the folder
    • Inside the extracted folder, create a new folder and name it data
    • Inside the data folder, create a new folder named db

    This is what your folder structure should look like now:

    --Connecting to MongoDB

    • Open you Machine's console, and change the current directory in the console to the directory of the bin folder in the mongo folder. You can do this by entering the command below:

    >cd pathToYourBinFolderInYourMongoFolder

    • After changing the directory in the console, enter the following command:

    >mongod --dbpath pathToYourDataFolderInYourMongoFolder

    ** Remember to click enter after entering each commands

    After going through those steps, your console should be looking like(not exactly) the image below:

    And that's all!! Your MongoDB is up and running!!😁😁😁

    Now, To check if your MongoDB is working perfectly, Open a new console

    NOTE: Do not close the first console! Just open a new one

    After Opening the new console, just enter

    mongo
    as a command.

    Then enter the following commands to create a document in the test collection:

    >db.test.save( { a: 1 } )

    And you'll get a Successfully Inserted reply

    AND THAT'S ALL!! AT LEAST FOR SETTING UP THE DATABASE😁😁😁😁


    SETTING UP MONGODB COMPASS

    1. Visit this page to download the MongoDB Compass
    2. Select your Machine's Operating system in the platform tab
    3. And the Most important part here, the Package Tab. Make sure you select the ZIP option, and download

    After downloading the zipped folder, Extract and rename the folder to Compass so as to easily locate it.

    Inside the folder, you'll see an application called MongoDBCompass, Open that application

    Enter the MongoDB connection string (

    mongodb://localhost:27017
    ) in the connection string field and click connect..

    A list of your Collections will be displayed

    And That's All!!

    Note: Before running your Compass, Make sure your MongoDB is already running in the console!!