Setting up MongoDB(4.2.10) and MongoDB Compass Locally
Tags: javascript, mongodb, computerscience, database
Published: 2020-11-22 01:47:11

#**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**
* Visit the [Official MongoDB website](https://www.mongodb.com)
* In the MongoDB homepage, hover over the **Software** tab in the Navigation Bar and click on [Community Server](https://www.mongodb.com/try/download/community)
* In the right side of the [Community Server Page](https://www.mongodb.com/try/download/community), there is a section with the title **_Available Downloads_**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7yj53rplkohxyn5xyc8z.png)
* 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
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oj7u7l8wjzbkwk008956.png)

#**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:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1nxpvdjburldhx5504y1.JPG)

#**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
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vqam52syebzwe5sor6sv.JPG)

* After changing the directory in the console, enter the following command:
```
> mongod --dbpath pathToYourDataFolderInYourMongoFolder
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zxqgfugtg2t5d80detne.JPG)

****Remember to click enter after entering each commands****

####**After going through those steps, your console should be looking like(_not exactly_) the image below:** 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/r9i1zzufligf15ftee3n.JPG)

####**_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.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0puerjbzfe1x4bf8mz9e.JPG)

Then enter the following command to create a document in the test collection:
```
> db.test.save( { a: 1 } ) 
```
And you'll get a **Successfully Inserted** reply

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ivzbki22sy9eopmjjppf.JPG)

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

#**SETTING UP MONGODB COMPASS**
* Visit this [page](https://www.mongodb.com/try/download/compass) to download the MongoDB Compass
* Select your Machine's Operating system in the platform tab
* And the Most important part here, **the Package Tab. Make sure you select the ZIP option**, and download
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hvkp4ew23afkibdm8l2f.png)

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4m5ht63bi83sw4k82pzg.JPG)

* Enter the MongoDB connection string (**_mongodb://localhost:27017_**) in the connection string field and click connect..
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ufic7c7nmxuyascyjzwz.JPG)

####A list of your Collections will be displayed:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bveezam2cnnh6nr621pd.JPG)


#####**And That's All!!**
#####**Note: Before running your Compass, Make sure your MongoDB is already running in the console!!**

If You like my Write ups, and would like to provide support to me and my work, and would also like to learn more about Programming/Software Development, Please do follow me on [Twitter](https://twitter.com/mccauley_json).