If you are looking for how to configure mongod as a windows service you can refer this post here.
Most of the time I observed that as a developer we don’t have linux box at our disposal to install softwares and play with them as in contrast ,99 % real world production applications are always being on running on RHEL (Red Hat Enterprise Linux) servers.
In this post we are going to install and configure MongoDB on a windows 8 machine, here I am assuming that you have a basic understanding of MongoDB and how it is different from normal RDBMS. If you don’t have no need to worry you can refer this post to get the basic understanding. So , let’s start
Here, I am going to mention the steps in sequential order.
- Download the software from MongoDB official site. Select the Windows 64 bit.
- After download you will have a zip file in your local system, extract it and store the contents in location of your choice.
- Once you extracted it in your local system you will see a directory structure like this
In my case I have saved it in
- Open a command prompt from your windows and make this location your current working directory.
- Now execute the mongod.exe from there . Now when you execute this command you will see an error as mentioned below in the snapshot.
This is because by default mongo database server looks for default database location (datadb) while starting it, and if it didn’t find this location it will throw an error and will exit the process.
So, to overcome this error you have to create a directory structure like this somewhere in your local system and pass this location as an argument while starting the mongo database server. You should be happy to know that this is the location where all of your documents and collection objects are going to reside.
In my case I have defined /data/db location here at the same level in the hierarchy where my mongodb is extracted.
Now execute the mongodb command again and pass this location as an argument to it.
C:sauravmongomongodb-win32-x86_64-2008plus-2.4.9bin>mongod --dbpath C:sauravmongodbdata
This time you will observe that mongo database server has been started successfully and is running on the port 27017. So , now we are done with the installation and configuration of mongo database server.
- Open a new instance of command prompt and make the same location where you have saved mongodb files as your present working directory-
- You can also confirm your current database by issuing a db command on the shell.
So , now you have both mongodb server and client running in your system and you can start playing with the different commands that mongo shell provides you.
In the next we will see core components of a mongo db like documents , collections , objects , BSON, etc. Till then stay tuned.
Note : You can add this location C:sauravmongomongodb-win32-x86_64-2008plus-2.4.9bin to your PATH environment variable to avoid setting the present working directory everytime.
Latest posts by Saurabh Jain (see all)
- java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected - August 8, 2014
- org.datanucleus.store.rdbms.exceptions.MappedDatastoreException: INSERT INTO “TABLE_PARAMS” – Hive with Kite Morphlines - July 17, 2014
- java.io.IOException: can not read class parquet.format.PageHeader: null – Hive - July 12, 2014