In this tutorial, we will show you the best way to install MongoDB in the windows machine.
You should be familiar with the Windows command prompt (cmd).
you can be downloaded from its official website. You can download the MongoDB from here. Once you navigate to this website, you will find, there are different versions are available of MongoDB for the different operating systems on their official website.
So we have to choose according to our system configuration and download it.
Here you can see tow types of files are available i.e zip and MSI file. You can download the zip file.
Note: MongoDB doesn't require explicit installation like other software or application. Just download the zip file and configure it in any directory.
After downloading, unzip, or extract it to your desired location. Here we kept in E:\mongodb
There is a 'bin' folder available inside the folder and it contains approx. 13 application file that helps to run.
E:\mongodb\bin
MongoDB requires a data directory to store the data. You can crate this folder manually in any location "C:\data", will not create it automatically and this will be the path of storage location.
You can create a configuration file inside the folder called “mongo.config”. It is just like a text file. Here you can specify the storage data path location
##store data here
dbpath=D:\mongodb\data
The server will start by using the below command:
mongod --dbpath="C:\data" --storageEngine=mmapv1
Open a command prompt (cmd) inside the bin folder and type the above command. It will start the server and point your storage path to your given location. It also set the storage engine type.
From the above image, you can see that it show 'waiting for connections on port 27017'
Open another command prompt in the same bin location and type below command:
Command : mongo
It will connect with you.
Now you can see that the mongo server says the connection is accepted.
Now you are ready to write code or queries.
You can write the below command to list the default database
Command : show dbs
You can also read: Integrate MongoDB in CodeIgniter for database operation