Open In App

Installing MongoDB on Windows with Python

We would explain the installation of MongoDB in steps. Before you install, I would suggest everyone use ide spyder, Anaconda. 

Step 1 -> Install the community Edition Installation Link 



Step 2 -> Run the installed MongoDB windows installer package that you just downloaded. MongoDB get installed here->

C:\Program Files\MongoDB\Server\3.4\

Step 3 -> Let’s set MongoDB environment



md C:\data\db
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
"C:\Program Files\MongoDB\Server\3.4\bin\mongo.exe

Step 4-> Ready MongoDB Open Command Prompt(Admin mode) type->

mongod

NOTE : Till step 4 MongoDB will work only when the Command Prompt is open and it’s listening. Now we’ll see Extension to make it better. Below steps from step 5 to step 8 are optional : Step 5-> Open command prompt and run-

mkdir c:\data\db
mkdir c:\data\log

Step 6-> Create a configuration file at C:\Program Files\MongoDB\Server\3.4\mongod.cfg (name of file mongod.cfg)

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db

This can be created and saved in Admin mode of Notepad or Notepad++ or any other editor to run notepad admin mode press Ctrl + Shift + Enter. Admin mode of notepad will let you create mongod.cfg and save above text file. Step 7 -> Install the MongoDB service by starting mongod.exe with the –install option and the -config option to specify the previously created configuration file. Now run this command on command prompt

"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" 
--config "C:\Program Files\MongoDB\Server\3.4\mongod.cfg" --install

Step 8-> To start & stop MongoDB run To start :

net start MongoDB

To stop :

net stop MongoDB

NOTE : ALL commands are run on Command Prompt Admin mode, to open command prompt Admin Mode either open normal command prompt and press Ctrl+Shift+Enter or Right click on left windows icon start button where you can see the options. Step 9 -> Open Anaconda Command Prompt as shown in the image. Step 10 -> Install package to use MongoDB To install this package with conda run:

conda install -c anaconda pymongo 

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

Article Tags :