In this post I will briefly take you through the steps to i nstall and use MongoDB on your workstation. More detailed instructions on installing it as a service, configure MongoDB clusters will be covered in the subsequent posts.
First of all download the MongoDB installer from the Download Center. In this post, I have downloaded the 3.4.1 of MongoDB installer for Windows. Launching the Installer will take you to the following screen, click Next and accept the agreement.
Chose “Complete” in the following screen.
Within a couple of minutes, the installation will succeed.
Now the installation is done but where did it install MongoDB? By default, it is installed in
C:\Program Files\MongoDB\Server\3.4\bin folder.
To avoid changing to this directory every time we want to use MongoDB, we can add this folder to the PATH environment variable as shown in the following screenshots.
After this whenever we open a command prompt, we can call any MongoDB binary without switching to the default installation folder.
Now we are good to launch MongoDB. But there is one important step that we need to take care before starting MongoDB. While starting MongoDB, it looks for the default data directories and creates the databases in that folder. On Windows the default data directory is c:\data\db. In case this folder structure does not exist, we need to create it manually either in command prompt or in Windows Explorer.
Once this is done we are good to launch MongoDB. To do this open a command prompt window and type mongod. Within a few seconds, MongoDB process is launched and it starts waiting for connections on the default port 27017.
Once the process is launched we can connect to it and work normally on a different command prompt window (since the process is running in the current window). There are some very good GUI based MongoDB clients, MONGO is a simple command line MongoDB shell.
Just typing MONGO in a command prompt window will connect to the local instance of MongoDB as seen in the following screenshot.
Hope you liked my first post on MongoDB. In the subsequent posts, I will cover various aspects of administering and development in MongoDB.