Pre-built binary packages of MongoDB are available for both 32 bit and 64 bit. You can download it, and install.
Here is the link to download pre-built binary packages of MongoDB : http://www.mongodb.org/downloads
After downloading the zip file, unzip it to the folder where you want to install.
MongoDB stores data in db folder within data folder. But, since this data folder is not created automatically, you have to create it manually. Remember that data directory should be created in the root (i.e. C:\ or D:\ or so).
For this tutorial, we have unzipped it within mongodb folder within D: drive. Now, we will create a folder called data and within that we will create a folder called db.
It is not necessary to perform the above operation from the command prompt. You may opt to do this from Windows Explorer also.
To run MongoDB server from the command prompt, you have to execute mongod.exe file from bin folder of mongodb folder.
Remember that you must have administrative privilege to run the following command. Run the following command to install MongoDb as a Windows Service :
mongod --bind_ip yourIPadress --logpath "C:\data\dbConf\mongodb.log" --logappend --dbpath "C:\data\db" --port yourPortNumber --serviceName "YourServiceName" --serviceDisplayName "YourServiceName" --install
The following table shows what does different arguments specify :
|--bind_ip||Specify your IP address following this.|
|--logpath||Specify the file of the logfile following this.|
|--logappend||Specify this so that logs are appended to the log file.|
|--dbpath||Specify the path of the db folder within data folder.|
|--port||Specify the port you want to use. Default port is 20127. If this argument is not specified, default port is used.|
|--serviceName||Specify the service name you want to opt for, following this.|
|--serviceDisplayNam||Specify the service name you want to opt for, following this, if you have more than one MongoDB services running.|
|--install||Specify this to install MongoDB as a Windows Service.|
db command will show you the list of documents(databases).
We will insert a simple record and retrieve the data now.
The first command inserts 10 to the x field, to the w3r collection(table)
Solve these problems: