In this tutorial, we will show you how to install MongoDB on Windows7 step by step.
- MongoDB 2.2.7
- Windows 7
• Extract the zip file to one of the drives
Example i extracted to C:\\mongoDB folder you can see below executables in bin folder.
• Configuration File
Create a folder “data” and “log” in the same drive
C:\\mongoDB\data
C:\\mongoDB\log
Create a MongoDB config file, it’s just a text file, for example
C:\\mongoDB\mongo.config
##store data here
dbpath=C:\Training\Trainings\mongoDB\mongodb\data
##all output go here
logpath=C:\Training\Trainings\mongoDB\mongodb\log\mongo.log
##log read and write operations
diaglog=3
• Run MongoDB Server
C:\\mongoDB\bin > mongod.exe --config C:\mongodb\mongo.config
all output going to: C:\mongoDB\log\mongo.log
log file [C:mongoDB\log\mongo.log] exists; copied to temporary file [C:\mongoDB\log\mongo.log.2014-12-30T17-56-02]
• Connect to MongoDB
Use mongo.exe to connect to the started MongoDB server.
C:\\mongoDB\bin > mongo.exe
MongoDB shell version: 2.2.7
connecting to: test
>
• Run MongoDB Server AS Windows Service
Add MongoDB as Windows Service, so that MongoDB will start automatically following each system restart.
Install as Windows Service with --install.
C:\\mongoDB\bin > mongod.exe --config C:\mongodb\mongo.config --install
Note: run the Command Prompt with Administrative Privileges to start MongoDB as Service.
A Windows service named “MongoDB” is created.
Install as Windows Service with --install.
C:\\mongoDB\bin > mongod.exe --config C:\mongodb\mongo.config --install
Note: run the Command Prompt with Administrative Privileges to start MongoDB as Service.
A Windows service named “MongoDB” is created.
• To start MongoDB Service
net start MongoDB
• To stop MongoDB Service
net stop MongoDB
• To remove MongoDB Service
C:\mongoDB\bin>mongod --remove
No comments:
Post a Comment