Installation of MongoDB is pretty easy, to run the installer downloaded from the downloads section here. The pre-requisites of the installation is just a Windows system and the MongoDB installer from the step above. Let’s check the Official MongoDB downloads section for the right zip file to download.
From MongoDB version 2.2, installation does not support Windows XP anymore and hence is suggested to choose to install on Windows Vista or Windows 7 or on Windows Server 2008 R2.
MongoDB " "
Related blog: MongoDB Atlas
The downloaded file: mongodb-win32-x86_64-2008plus-3.4.7-signed.msi. Having said that, let’s get down to business installing the above.
Once the download finishes, identify the downloaded installer file and double-click the .msi file to initiate the installation process, which will take you through the following installation screens.
A point to remember is that MongoDB is a self-contained database and hence doesn’t have any other system dependencies along with it. Once the installation is complete, you can run MongoDB from any folder of your choice.
Click Next on the screen above
Click on the ‘I accept the terms in the License Agreement’ checkbox and then click on the Next button.
Click on the ‘Complete’ button to progress further, if you wish that the installer chose the directory and what needs to be installed on the Computer (which is by default, the recommended option), but if you want to be choosy in what needs to be installed and where each of these components to be installed then you may go with the ‘Custom’ option.
Considering that you’ve chosen to go by the recommended option of ‘Complete’, the above screen appears to trigger the actual installation process by clicking on the Install button.
Once the installation process completes, this is the screen that confirms it.
Clicking on the Finish button finishes the process.
In the process above, you were able to control the installation process and it was an interactive process wherein your key in your requirements and based on that the installation progresses. Here we are going to introduce to you a way of installing MongoDB in a silent or an unattended manner using the MongoDB command-line utility.
Take a look at the following steps on how to do the same:
For example, if we want to install only the MongoDB Server and Client on your system then you can choose to run the following command only to install these two components.
The steps above enable you to install the MongoDB related components via the interactive installer installation or the silent installation (the choice is all yours). Now that we have installed the MongoDB database, let us see how we can run this to start the database as such.
A point to note here that by design, MongoDB should be run in trusted environments and the database doesn’t support ‘Secure mode’ by default. Hence it is very important that we don’t make mongod.exe visible and vulnerable on public networks without running it in ‘Secure mode’ with the needed authentication settings. With those points discussed, let’s set up our MongoDB one time configurations to get it started.
MongoDB requires a data directory in order to persist all the data. The default data directory path for MongoDB is the absolute path datadb on the drive where we start the MongoDB service.
Or we can choose a specific folder path by using the –dbpath parameter while we run the mongod.exe. If your path contains spaces then you need to add the path using double quotation marks, else you can use it as shown below.
"C:Program FilesMongoDBServer3.4binmongod.exe" --dbpath E:MongoDBdata
To start the MongoDB database, simply run the mongodb.exe using the command given below on a Command prompt. If you can wait and check for the following string “waiting for connections”, then it is evident that the mongod.exe process is running successfully
To connect to the MongoDB we can use the mongo.exe shell, by opening it in another command prompt using the command shown as below:
To stop the MongoDB database instance, you can press CTRL + C on the same command prompt terminal where the mongod instance was running earlier.
Earlier, you’ve seen how to start the MongoDB services via the MongoDB utilities. This section talks about creating a Windows service to start and stop MongoDB services via the Services tool, let’s see how this can be achieved:
Create a configuration file, systemLog.path to redirect all the diagnostic logging information from the mongod and mongos services. Any other additional configuration that is needed can also be made at this point, please refer to the Official MongoDB documentation for this purpose.
You can create this configuration file under the MongoDB installation path,
“C:Program FilesMongoDBServer3.4mongo.cfg” specifying both the systemLog.path and storage.dbPath.
Open a command prompt as an Administrator and install the MongoDB service by using the mongod.exe command and also using the –install option and then to use –config option to mention the configuration file created in the step above.
"C:Program FilesMongoDBServer3.4binmongod.exe" --config "C:Program FilesMongoDBServer3.4mongod.cfg" –install
You can install the services with a meaningful name using the – serviceName and – serviceDisplayName parameters for each of mongod.exe and mongos.exe.
You can run the following command to start the MongoDB service
net start MongoDB
To stop the MongoDB service, you can run the following command
net stop MongoDB
To remove or to uninstall the MongoDB services, you can use the following command
"C:Program FilesMongoDBServer3.4binmongod.exe" –remove
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
|MongoDB Training||May 23 to Jun 07|
|MongoDB Training||May 28 to Jun 12|
|MongoDB Training||May 30 to Jun 14|
|MongoDB Training||Jun 04 to Jun 19|
Prasanthi is an expert writer in MongoDB, and has written for various reputable online and print publications. At present, she is working for MindMajix, and writes content not only on MongoDB, but also on Sharepoint, Uipath, and AWS.
Copyright © 2013 - 2022 MindMajix Technologies