MongoDB installation :
In this post we are going to see installation of mongoDB on windows machine.
Installation of mongoDB is very simple. Just download the .msi file from mongoDB website and execute it by pressing next, next,..Finish.
You can download it from below mentioned Hyperlink.
Once you downloaded, double click on the file to run.
Then a wizard will be opened as shown in the below figure.
Click on NEXT, and accept the service agreement, then click on install to finish installation.
That's all. You've successfully installed mongoDB in your windows machine.
Adding Environment variables :
After completion of installation, we should add the "MongoDB BIN" location to environmental variables. To do this, first check where the mongoDB has been installed on your windows machine. By default, it will be installed in "\Program Files" on the current volume on windows. In my case it was,
C:\Program Files\MongoDB\Server\3.2\bin
Go to the "bin" directory and copy the complete path. Here, you can see that all MongoDB package components are placed here.
Now, go to the "system properties", and add the copied path to "PATH" variable under "Environment variables ==> system variables".
We are done !!
Test run :
Open a command prompt, and just type 'mongod' to start mongod server on default port i.e. 27017.
When we run with no arguments, mongod will use the default data directory, \data\db\ on the current volume on Windows. If the data directory does not already exist or is not writable, the server will fail to start. It is important to create the data directory (e.g., mkdir data\db) and to make sure your user has permission to write to the directory before starting MongoDB.
On startup, the server will print some version and system information and then begin waiting for connections. By default MongoDB listens for socket connections on port 27017. The server will fail to start if the port is not available. The most common cause of this is another instance of MongoDB that is already running.
mongod also sets up a very basic HTTP server that listens on a port 1,000 higher than the main port, in this case 28017. This means that you can get some administrative information about your database by opening a web browser and going to http://localhost:28017
You can safely stop mongod by typing Ctrl-C in the shell that is running the server.
MongoDB shell :
MongoDB comes with a JavaScript shell that allows interaction with a MongoDB instance from the command line. The shell is useful for performing administrative functions, inspecting a running instance, or just playing around. The mongo shell is a crucial tool for using MongoDB and is used extensively throughout the rest of the text.
Running the shell
To start the shell, run mongo executable :
On startup, the shell connects to the test database on a MongoDB server and assigns this database connection to the global variable db. This variable is the primary access point to your MongoDB server through the shell.
To see the database db is currently assigned to, type db and hit Enter:
Thank you for useful information
ReplyDeleteFull Stack Training in Hyderabad
Full Stack Training in Ameerpet
Thanks for your post...
ReplyDeleteMean stack online training
Mean stack training in hyderabad