This article brings you a detailed explanation of the environment configuration tutorial of mongoDB under Windows. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Download and install from the official website, you can choose the specific path for installation.
In order to start mongoDB conveniently, we can add the mongo.exe path to the environment variable, Computer->Properties->Advanced System Settings->Environment Variables, add the path to path. In this way, you can use the mongod command everywhere
Create a new mongoDB folder on the D drive to store data files and create data and log folders under it. Create the mongodb.log file in the folder
Start the mongodb service, open the command line and enter
mongod --dbpath "D:\mongodb\data" --logpath "D:\mongodb\log\mongodb.log" --logappend
Enter the command line mongo and the following interface will appear and explain that the installation is successful
* *Analysis: The mongod --dbpath command is to create the storage location of the database file. When starting the mongodb service, you need to determine the storage location of the database file first, otherwise the system will not automatically create it and the startup will be unsuccessful.
--logpath represents the path where the log file is stored
--logappend represents writing the log file in an appended manner **
You need to enter the above command every time you start the service. For convenience, you can write the startup database as a window service.
mongod --dbpath "D:\mongodb\data" --logpath "D:\mongodb\log\mongodb.log" --logappend --directoryperdb --install
After the above steps, we have registered the MongoDB service into the system service. It will be started when the system is turned on, so if we turn it on again, Open cmd as an administrator and enter net start MongoDB. We will be prompted that the service we requested has been started. Therefore, when we turn on the computer next time, we don’t need to do anything. The MongoDB service has already been started, and we can use MongoDB.
Enter the cmd operating environment of mongoDB, and enter the command after all the above configurations are completed. Run mongo to enter, ctrl C is to exit the environment.
Stop the service
net stop MongoDB
Restart the service
net restart MongoDB
Uninstall the service (stop the service first)
Note: The path and file name in the above command must still be consistent with those created by yourself, the same below
mongod --dbpath "D:\mongodb\data" --logpath "D:\mongodb\log\mongodb.log" --logappend --directoryperdb --remove
Reinstallation Service
mongod --dbpath "D:\mongodb\data" --logpath "D:\mongodb\log\mongodb.log" --logappend --directoryperdb --reinstall
The above is the detailed content of Detailed explanation of mongoDB environment configuration tutorial under windows. For more information, please follow other related articles on the PHP Chinese website!