Installing Zip version of MongoDB in Windows

Introduction

Here I will tell you how to install zip version of MongoDB in Windows environment. I will install here MongoDB Community edition. If you want to install MongoDB msi version then you can read Step 4 at https://roytuts.com/mongodb-php7-xampp-windows/. We will download latest(as of today) MongoDB server 4.4.0 and configure in Windows environment.

Download MongoDB

The first step would be to download the MongoDB server community edition from MongoDB Download Center.

Choose the ZIP version of your package and choose your Operating version similar to the below image:

installing zip version of mongodb in windows

Here I have chosen Windows as a platform, you can choose as per your Operating System version.

You must select the Package as ZIP.

Now click on Download button and save into an appropriate location on your computer’s disk.

Install MongoDB

Now extract the zip file into a drive, for example, C:\. You can also extract in any location as per your choice or requirements.

Create Directory – data\db

Now create a directory called data\db in parallel to the root directory of the MongoDB extracted folder.

The data\db directory is required to save the database records.

Remember if you do not create such directory then you will get below error in the console output while you will try to run the MongoDB server at later point of time:

exception in initAndListen: NonExistentPath: Data directory <disk drive of mongodb installation root directory>:\data\db\ not found., terminating

Run the MongoDB Server

No we will run our MongoDB server by executing the following command from cmd window.

Navigate to the <MongoDB root directory>/bin folder in cmd window and execute the mongod.exe file.

For example,

C:\mongodb-4.4.0\bin>mongod.exe

Once your server starts successfully, you will see similar to the below output in the console:

installing zip version of mongodb in windows

Run MongoDB Client

We want to test whether our MongoDB server is running or not and perform some database operations. So run the mongo.exe file in the bin folder in cmd window.

For example,

C:\mongodb-4.4.0\bin>mongo.exe

Once your MongoDB client successfully connects to the mongoDB server, then you will find below output along with other output:

installing zip version of mongodb in windows

So a session will be established with your server for allowing client perform database operations.

Performing MongoDB Operations

I will show you few basic things here but you can always find more commands here.

The default database that comes with MongoDB is test.

We will perform all operations on MongoDB Client using the command.

Creating Database

Create a new database by using below command on the MongoDB Client terminal.

use roytuts

Checking Database

Now we will check what is our current database we are using for our application by using below command.

db

The above command will show you the database roytuts.

Creating Collection

We have created database, now we need to create collection, where our data will be stored.

Use below command to create a collection called user:

db.runCommand( { create: "user" });

Selecting Collections

You can select collections for your current database using below command:

db.getCollectionNames();

You can find below image to see what are all outputs for the above commands executed.

installing zip version of mongodb in windows

Removing Records From Collection

If you want to remove all records from a collection, then you can execute below command.

db.user.remove({})

Where user is the name of the collection.

If you want to remove a particular record, for example, you want to remove a user whose name is Soumitra, then you can use below command.

db.user.remove({"name":"Soumitra"})

Dropping Collection

To drop a collection from database you can execute below command.

db.user.drop()

Where user is the name of the collection.

That’s all. I hope you got an idea on installing zip version of MongoDB in Windows environment.

Thanks for reading.

4 Thoughts to “Installing Zip version of MongoDB in Windows”

  1. Palash Anjania

    when I type mongod.exe exactly as you have directed, it does nothing, a new line on the command prompt is prompted

    1. if you are not getting any error then you can remove mongodb directory and data directory completely and try reinstalling.

  2. Ankita

    Thanks alot
    great help

  3. moslem

    that was really helpful. thank you very much. :)

Leave a Comment