Download the current MongoDB windows installation .msi file from https://www.mongodb.org/downloads matching your requirement.
Run the file and carry out the installation process. It is easy. You will be guided through the installation process.
PS: The 3.2 and 3.0 releases of MongoDB does not work in windows. But the older releases does. In my case, I installed MongoDB 2.6 Standard version.
Now open the command prompt and go to the bin folder of the MongoDB installation. In my case, it is C:\Program Files\MongoDB 2.6 Standard\bin
Run the mongod.exe file there by typing the command
mongod
You will find an error saying \data\db does not exists as shown in the figure below, and the .exe stops.
Then go to the directory where MongoDB is installed and create a folder structure named data/db. But you can create it where ever you like. In my case it is as above.
Then run the following command in the command prompt.
mongod --dbpath="C:\Program Files\MongoDB 2.6 Standard\data"
You will see the following.
To test the installation, keep this command prompt as it is, and open a new command prompt and type the command
mongo.exe
while in the same bin directory above. You will see the following output.
PS: See there are 2 command prompts in the above figure.
MongoDB gets created with a test database called "test". We can verify the correctness of our installation by issuing a query to this test database.
Type in the following commands.
> db.test.save({TharikasTestField:'My name is Tharika!'})
This query will insert a record to the test database, "test" is the name of the database. save() is to insert a record. Then you give the field and the value in curly brackets separated by a colon.
> db.test.find()
This command will printout the inserted record as shown in the following figure.
So you can see that we have successfully setup MongoDB on windows. Cheers! :)
Comments
Post a Comment