How to install MongoDB for development in Windows

Posted on July 2nd 2018 by Zarko

How to install MongoDB for development in Windows

2. MongoDB setup


Be sure to visit my new YouTube channel linked below! Also, if you found the tutorial useful please take a second to like the video and subscribe for more content in the future!

MongoDB Logo

Visit the MongoDB Download Center by clicking on the following link:

Select the ‘Community Server’ option, make sure Windows is selected as your operating system and click the download button.

MongoDB Windows Download Page

After the download finishes, run the MongoDB .msi installation file (press ‘Run’ when the Window security dialog pops up)

1) Press the ‘Next’ button

MongoDB Windows Installation

2) Tick the ‘I accept the terms in the License Agreement’ checkbox (after reading the license agreement carefully, of course)

MongoDB Windows Installation

3) Select the ‘Custom’ button so we can change the install folder location

MongoDB Windows Installation

4) Click ‘Browse…’ on the bottom right

MongoDB Windows Installation

5) Now type C:\MongoDB\ in the ‘Folder name’ input field and press ‘OK’

MongoDB Windows Installation

6) Check if everything looks good and then press ‘Next’

MongoDB Windows Installation

7) Untick the ‘Install MongoD as a Service’, since we will be starting our database manually.

MongoDB Windows Installation

8) Untick ‘Install MongoDB Compass’ as shown in the screenshot and click ‘Next’ again

MongoDB Windows Installation

9) Finally, click the ‘Install’ button (Press ‘Yes’ on the User Account Control dialog from Windows)

MongoDB Windows Installation

10) Press the ‘Finish’ button to complete the installation process

MongoDB Windows Installation

Post-install Configuration

11) First thing we will do is create the data folder for MongoDB.

Start Windows Powershell (press the Windows Start button and type ‘powershell’ to find the shortcut) and type the following command:

New-Item -ItemType directory -Path C:\data\db

Powershell MongoDB data folder creation

Alternatively, you can manually create these folder by going into your C:\ drive with the file explorer, then create a new folder called ‘data’

Go into the newly created folder called ‘data’ and create a new folder inside of it, called ‘db’

12) To easily start our mongod server and mongo terminal, we will create a Windows batch script file (.bat) which will serve as a shortcut for us.

Open a new file in your code editor and paste in the following:

@echo off
cd "C:\mongodb\bin"
start mongod.exe
timeout 4
start mongo.exe

Then, press Save (Ctrl+S), navigate to your desktop and save the file as ‘StartMongo.bat’

Sublime Text MongoDB configuration

13) Now you will be able to start your mongod database server and the mongo terminal by double-clicking the StartMongo.bat file on your Desktop!