Installation and configuration of MongoDB under WIN10 and common errors!

1. First go to the official website to download the latest version of MongoDB (https://www.mongodb.com/download-center?jmp=nav#community) and install it.


2. Configure environment variables


3.Create a data directory data folder in the F:\mongoDB file, and create a db folder in the data folder.


4. Create the log directory logs folder in the F:\mongoDB file, and create the mongodb.log file in the logs folder.


5. Create the configuration file mongod.cfg in the F:\mongoDB file, and type the following in the mongod.cfg file:


systemLog:
    destination: file
    path: F:\mongoDB\logs\mongodb.log
storage:

    dbPath: F:\mongoDB\data\db


6.Enter the command F:\mongoDB\bin\mongod.exe --dbpath F:\mongoDB\data\db in cmd, as shown below:


Wait to connect to port 27017, 27017 is the default port. Do not close cmd at this time.


7. Reopen cmd and enter the command F:\mongoDB\bin\mongo.exe, as shown below:


At this time, the connection is successful, close the two cmd.


8. Open cmd with the administrator command, enter the command F:\mongoDB\bin\mongod.exe --config F:\mongoDB\mongod.cfg --install, at this time a new file should be generated in the logs file.


9. Enter the command under administrator authority: net start MongoDB, add the MongoDB service to WINDOWS, pay attention to the service name must not be wrong. If you are not sure about the service name, open the task manager, and view it as shown below:


After entering the command as shown below:



Common startup problems:

1. The service name is invalid, as shown below:


此问题一般由两个原因造成,第一可能是你的服务名称拼写错误,服务名称的查询上面有讲到过,第二就是没有用管理员权限运行命令.

2.服务无法启动,发生服务特定错误,如下图:


此问题一般是因为上一次非正常关闭MongoDB服务造成的,到db文件夹中找到mongod.lock文件删掉,重新启动服务即可.


转载自: https://blog.csdn.net/qq_33210798/article/details/74332549

Guess you like

Origin blog.csdn.net/qq_31281327/article/details/80148074