A Step by Step MongoDB Installation on Windows:
In this tutorial, we will see the installation and configuration setup of MongoDB, how it does and how a beginner with no background knowledge could install it easily without getting help from anyone.
What You Will Learn:
Pre-Requisite Information On Windows
The users of Windows must know that their windows desktop has got one of the two versions i.e. 32-bit & 64-bit.
This information could be found out in the properties of one’s “My Computer” or “This PC” on their device i.e. either their windows is 32-bit or 64-bit.
Further reading =>> Is My Windows 32 bit Or 64 bit
Meanwhile, in order to check the windows version, one can also use command prompt in the way as narrated in the snippet below:
The command is C:\>wmic os get osarchitecture
Figure 1: Command To Know Windows Version
After finding this out, the 32-bit windows users would follow the guide to install the version of MongoDB which supports 32-bit and vice versa. MongoDB is available in both the versions which support their respective 32-bit & 64-bit windows.
For instance, 32-bit windows users have got the advantage of having qualitative development and testing environments.
Meanwhile, if one must get into production environments, then they must have to adopt 64-bit windows, because in this case, using 32-bit would limit the data usage which would be stored in MongoDB. Therefore, the 32-bit windows version supports the MongoDB version which has the database size lesser than 2 GigaBytes.
MongoDB Download On Windows
Click on the following link to Download MongoDB On Windows
Figure 2: To Get the Download File of MongoDB from Website
Click on any one of the following links which suit your Windows Version.
Installation Guide On Windows
Follow the below steps to install the proposed file:
Step 1: Open the file. We have installed for 64-bit version with the name as “MongoDB-win32-x86_64-2008plus-ssl-v3.4-latest-signed”. It is saved in the Local Disk C:/, click on the file where you’ve saved it to start the wizard.
Step 2: Click “Next“.
Step 3: Tick the check box next to ‘I accept the terms in the License Agreement’ and again click on “Next“.
Step 4: Click “Complete” to install all the features of MongoDB. As for “Custom”, this option would be used to install only the specific components of MongoDB and also if a user wants to change the location of where the installation must be done.
Step 5: Click “Install” to begin the installation drive.
Step 6: After the installation has been finished. Simply, click “Finish“.
Configuration Through Mongo Shell
After the whole installation is done, the user must configure it.
Follow the below steps:
If you use “mongo” in the command prompt without configuring it, then it would give an error. Hence, configure it first.
Step 1: Go to the local disk C and get into “Program Files“. There you’ll find a folder named “MongoDB“.
Step 2: Open it and you’ll find a folder named “bin” i.e. binaries folder. You will have 15 to 17 files in it. Copy the path, as given in the snippet path i.e. C:\Program Files\MongoDB\Server\4.0\bin
Step 3: Open Settings and search “Path”.
The two options given below would pop up in front of you:
- Edit environment variable of your account
- Edit the system environment variable.
Step 4: Click on “Edit the system environment variable” and then click on “Environment Variables“.
Step 5: In the Environment variable, you’ll see the path as given in the snippet. Click “Path” and then press “Edit“.
Step 6: In the Path given at your system, delete the previous ones and add new “The copied path” from binaries, and click “OK”.
Step 7: Open Command prompts and type “mongod” to start the service.
Step 8: Write command on the command prompt “mongo” to create the connection.
Step 9: Open Command prompt with admin privileges and type: md \data\db to make a directory which would be \data\db at the same folder.
Then, Get into the folder “data“, which would be in the same folder i.e. MongoDB at C:/ and then find the file named “mongod.lock“.
Step 10: Again, open Binaries i.e. “Bin” and find “mongod.cfg file”, if you find it, then copy this file and paste it in the folder named “data” which is also in the MongoDB folder in C:/. If it is not here then finding in the “data” folder might help, usually, it happens to be there.
Copy the path which is “C:\Program Files\MongoDB\Server\4.0\data” in your system.
Step 11: Open Command prompt with admin privileges and write this command: mongod –config “C:\ data\mongod.cfg” –install
Step 12: Again type the command: net start mongoDb
The MongoDB pops up with a message “The MongoDb Service was started successfully”. You are now good on the go. MongoDB has been successfully configured.
Configuration Through Robomongo i.e. Robo 3t
To configure MongoDB with non-commercial MongoDB management tool i.e. Robo 3t, one can easily use the full command on the mongo shell during configuration.
Step 1: Download Robo 3t and launch the installer.
Step 2: Click “I agree” to agree to the End-user agreement.
Step 3: Click “Next“.
Step 4: Click “Install“.
Step 5: Click “Finish“.
Step 6: Launch the Application & Click “I agree” to the agreement.
Step 7: Click on “Create” to create a new connection and save the address & port as it is given.
Step 8: Click On “Connect“. Once it is connected, the user could view all the databases, collections, and documents. Through UI, one can insert Documents, delete, update and find documents.
Step 9: Open Command prompt with admin privileges and type: md \data\db in order to make a directory which would be \data\db at the same folder.
MongoDB would create the database directly at the same folder or location as it would be the default location of MongoDB to store information. It is done to make sure that MongoDB would find the directory at the same location when it would start.
The data import through Robo 3t is done and could be seen by using the mongoimport command with some data to be stored.
These are the steps to get MongoDB installed in your system.
In the above installation, the latest version of MongoDB software has been installed from the website. A user must be sure about the version which has to be the latest one.
We have now successfully installed the NoSQL MongoDB.
Check out our upcoming tutorial to know more about Create and Insert Database in MongoDB!!