In the previous tutorial, we have learnt about Introduction, Overview, Advantages, Features and when to use MongoDB. In this tutorial we will learn how to setup MongoDB in our local machines. We will be covering steps to install MongoDB and related tools on Windows operating system and Linux operating system.
Installing MongoDB on a Windows machine is very easy. Below are the steps involved in installing the MongoDB:
.msi
file from the site MongoDB Download Centre. Select the latest version for Windows, the Windows Server 2008 R2 is the version if you are on Windows 7, 8 or 10.
.msi
file to start the installation. Select the option Custom during the installation process, to specify a custom location where you want MongoDB to be installed. By default it is installed in C:\mongodb
directory.D:\java\mongodb
Component | .exe File |
---|---|
Server | mongod.exe |
Router | mongos.exe |
Client | mongo.exe |
data\db
. It is best practice to create this directory under the folder where the MongoDB is installed. So let's create a folder named data and one more folder named db inside data folder as shown below.
FILE_NAME.log
. mongod.exe --dbpath "DATA_DIRECTORY_PATH"
to configure the data path and start the MongoDB server. Please replace the DATA_DIRECTORY_PATH with the path of data directory present inside MongoDB installed folder. On running this command, the below log will be displayed which says that the MongoDB configuration is successful and the server is up and running fine.
mongo
in Command Prompt and it will get connected to the MongoDB where the default database is test.