To install MongoDB on Windows, first download the latest release of MongoDB from https://www.mongodb.org/downloads. Ensure that you get correct version of MongoDB based upon your Windows version. To get your Windows version, open command prompt and execute below command.
32-bit versions of MongoDB only support databases smaller than 2GB and are appropriate only for testing and evaluation purposes.
Now extract the downloaded file to c:\ drive or any other location. Ensure that the name of the extracted folder is mongodb-win32-i386-[version] or mongodb-win32-x86_64-[version]. Here [version] is the version of MongoDB download.
Next, open the command prompt and run below command.
If you have extracted MongoDB in a different location, then go to that path by using command cd FOOLDER/DIR and run the above given process.
MongoDB needs a data folder for storing its files. Default location for MongoDB data directory is c:\data\db. Therefore you have to create this folder using the Command Prompt. Execute below command sequence.
If you want to install MongoDB at a different location, then you have to specify an alternate path for \data\db by setting the path dbpath in mongod.exe. For the same, issue below commands.
In the command prompt, navigate to the bin directory present in the MongoDB installation folder. Suppose my installation folder is D:\set up\mongodb
This will show waiting for connections message on the console output, which indicates that the mongod.exe process is running successfully.
Now to run MongoDB, open another command prompt and run below command.
This will show that MongoDB is installed and run successfully. Next time when you run MongoDB, you have to run only commands.
Run below command to import the MongoDB public GPG key –
Create a /etc/apt/sources.list.d/mongodb.list file using below command.
Now run below command to update the repository –
Next install MongoDB by using below command –
In the above installation, 2.2.3 is currently released MongoDB version. Ensure to install the latest version always. Now MongoDB is installed successfully.
To use MongoDB, run below command.
This will connect you to running MongoDB instance.
To get a list of commands, type db.help() in MongoDB client. This will provide a list of commands as shown in below screenshot.
To get stats about MongoDB server, type the command db.stats() in MongoDB client. This will show the database name, number of collection and documents in the database. Output of the command is shown in below screenshot.
MongoDB Related Interview Questions
|Python Interview Questions||C & Data Structures Interview Questions|
|Hadoop Interview Questions||Node.js Interview Questions|
|Scala Interview Questions||Socket Programming Interview Questions|
|HBase Interview Questions||Solaris Administrator Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.