MongoDB Installation Guide with Python | Windows

Python Methods and Functions

Step 1 - & gt; Install Community Edition
Installation link

Step 2 - & gt; Run the installed MongoDB Windows Installer package you just downloaded.

MongoDB is installed here- & gt;

  C: Program FilesMongoDBServer3.4  

Step 3 - & gt; Let's install the MongoDB environment

  • (a) Create a data directory where all data is stored.
    On drive C: create a data folder, inside create the db folder
     md C: datadb 
  • (b) Start MongoDB
    Run - & gt;
     "C: Program FilesMongoDBServer3.4inmongod.exe" 

    Wait until the connection message appears

  • (c) Check the Environment Path or set the path if it is not set correctly
    Open the environment variables, you can search for this using Windows search. 

    Open your environment variable under System Variables, open Path. 
    It will look like this

    Add the path to the bin folder as shown in the picture above.

  • (d) To connect to MongoDB
    Open another command line and run- & gt;

     "C: Program FilesMongoDBServer3.4inmongo.exe 

Step 4- & gt; Ready MongoDB
Open Command Prompt Type (Admin Mode) - & gt;


NOTE. Until step 4 MongoDB will only work with the command line open and listening.
Now we will see an extension to make it better.

Below steps from step 5 to step 8 are additional:
Step 5- & gt; Open a command prompt and run-

 mkdir c: datadb mkdir c: datalog 

Step 6 — & gt; Create a file to config in C: / Program Files / MongoDB / Server / 3.4 / mongod.cfg (filename mongod.cfg)

 systemLog: destination: file path: c: datalogmongod.log storage: dbPath : c: datadb 

This can be created and saved in Notepad admin mode or Notepad ++ or any other editor, to launch Notepad admin mode press Ctrl + Shift + Enter . Notepad admin mode will allow you to create mongod.cfg and save the above text file.

Step 7 - & gt; Install the MongoDB service by running mongod.exe with the –install option and the -config option to point to the previously generated config file.
Now run this command on the command line

 "C: Program FilesMongoDBServer3.4inmongod.exe "--config" C: Program FilesMongoDBServer3.4mongod.cfg "--install 

Step 8 - & gt; To start and stop MongoDB starting

 net start MongoDB 


 net stop MongoDB 

ALL commands are run in command line admin mode to open a command prompt, in administrator mode, either open a regular command prompt and press Ctrl + Shift + Enter, or right-click the launch button of the left window icon to view the options. 

Step 9
- & gt; Open Anaconda command prompt as shown in the picture. 

Step 10 - & gt; Install package to use MongoDB
To install this package using conda run:

 conda install -c anaconda pymongo 

Congratulations !! Installation completed. (Pymongo only works when MongoDB starts, use net start MongoDB to start it and then work on spyder)
You can learn and understand MongoDB in Python here .

This article courtesy of SHAURYA UPPAL . If you are as Python.Engineering and would like to contribute, you can also write an article using or by posting an article contribute @ See my article appearing on the Python.Engineering homepage and help other geeks.

Please write in comments if you find anything wrong or if you'd like to share more information on the topic discussed above.