Tired of clicking to your mongodb installation folder to spin it up!! Never again! Setting path for mongodb

Long title huh? Leave it alone just dive into the content then you will get the meaning of it 🙂

Mongodb is one of the fastest evolving nosql databases. And in an effort to learn it, I have found myself so stuck into it. It sometimes come with it own developer challenges. And in this series of posts to follow, I will be highlighting what I have and will find interesting and worthy sharing with you.

My assumption in these posts is and will be that you have downloaded mongodb here and installed it your machine as per the well documented installation guide.

In my case, I did that on my box running windows 8.1, and my installation path was “C:\Program Files\MongoDB\Server\3.0\bin”. At first I was very excited to run “cd” or better “pushd” to this directory to spin up my mongod.exe instance like show:

How to start manually

After a few times of doing this, it became kind of boring and I started to research on a better way to do this.  The simplest solution that I found was to add the mongodb bin installation path (“C:\Program Files\MongoDB\Server\3.0\bin”) to the system environment path variable. So copy the path to your clipboard, the go my computer and follow the step as highlighted below.

NB: Assumption here is that you are on windows 8.1/8. If not find out how to get to the “Advanced system settings” in your operating system.

add_path

Once you hit step 4, double click and you will definitely get a small pop up window, which allows you to edit the “Path” variable. You might find other paths there, seperated with semi-colon. You simply append the path on your clipboard, and make sure you separate with semi-colon as well. After successfully pasting your path and made sure it looks like I have highlighted in yellow, just click ok to all the opened windows.

And with that in place, you can simply open any command prompt, including “cmd” and type any mongodb command e.g mongod.exe, mongo.exe etc like show below.  You will need to close any opened prompts to achieve get the effects, by this I mean for any opened prompt the following will not work, you will need to close it.

Updated_screen

You can see now, I don’t have to navigate to the installation directory to spin up mongod instance. Just from my command prompt, I can now run mongod.exe.

One of the reasons, I found this relevant to share is because there are alot of posts to follow regarding mongodb, and we will always be referring to this post for spinning up our mongodb instance.

Happy coding and keep an eye for the next post soon!

 

Advertisements

Tags: , , ,

About Piusn

Enthusiastic Software Developer

What's your thought on the subject?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: