win7 install and configure mongodb

The installation and configuration have been unsuccessful many times before. This time I finally succeeded. I wrote a blog post, and I can configure it smoothly next time.winkwink

1. Download and install

First, go to the official website (http://www.mongodb.org/downloads) to download the appropriate installation package. The installation package is available in zip and msi format (it is recommended to download the zip format here, and the msi version is actually just decompressed. And the installation path is not allowed to be selected during installation, the default installation is to the C:\Program Files\MongoDB\Server\3.4 directory)

Then select the 32-bit or 64-bit zip package according to your own system, and extract it to the D:\momgobd directory after the download is complete (this is optional, you can install it on which disk you like)



 

Create the database directory D:\mongodb\data, then open the command line window and switch to the D:\mongodb\bin directory (if there is no special instruction, open cmd in this folder)

 

Execute the following command: where --dbpath is the specified database storage directory, here we should pay attention to two "-"

mongod --dbpath D:\mongodb\data



After pressing Enter, the command line window will print some startup information. When the last line is displayed as shown below, it means that the startup is successful.



 

At this time, enter http://localhost:27017/ in the browser (the default connection port of mongodb is 27017), you can see the display


 The installation is successful here

 

2. MongoDB is installed as a Windows service

 

Installing mongodb as a windows service is very simple, just add --install after the command line executed above

mongod --dbpath D:\mongodb\data --install

 

According to the normal plot, the service should be installed successfully, but unfortunately, the following prompt appears

--install has to be used with --logpath

As prompted, we need to create the logs directory D:\mongodb\logs

 

then execute the command

mongod --dbpath D:\mongodb\data --logpath=D:\mongodb\logs\mongodb.log --logappend

 

Then use the sc command to create the service (MongoDB is the service name)

sc create MongoDB binPath= "D:\mongodb\bin\mongod.exe --service --dbpath D:\mongodb\data --logpath=D:\mongodb\logs\mongodb.log  --logappend"

 

After that use net start to start the service  

net start MongoDB

If you want to shut down the service, use net stop 

 net stop MongoDB 



 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326356997&siteId=291194637