This article is reproduced from http://blog.csdn.net/pupingpp/article/details/39053945, if necessary, please check the original text.
The following is a brief introduction to the installation of MongoDB on the Win7, as well as possible problems.
Note: MongoDB If you do not configure the default IP and port, the default IP is localhost, the port is 27017, and of course these parameters are configurable, not discussed here.
5, in order to observe the log information, the best start-up configuration log directory, such as my: D:\log\MongoDBLogs, so at startup, plus the--logpath parameter (specify to the specific file):
"D:\Program files\mongodb2.6\bin\mongod.exe"--dbpath "D:\ProgramData\MongoDB"--logpath "D:\log\MongoDBLogs\" MongoDB.log ";
Once started, the boot information is output to the MongoDB.log file.
6, of course, you can also put the boot information in a configuration file, start directly to read the file to get the above startup parameters, such as my: D:\Program files\mongodb2.6\mongod.cfg; mongod.cfg content is:
Logpath= D:\log\MongoDBLogs\MongoDB.log
Dbpath= D:\ProgramData\MongoDB
This command is used directly when booting: "D:\Program files\mongodb2.6\bin\mongod.exe"--config "D:\Program files\mongodb2.6\mongod.cfg";
Above the boot mode, after the system restarts to start MongoDB service, must execute the above command, "D:\Program files\mongodb2.6\bin\mongod.exe"--dbpath "D:\ProgramData\MongoDB "--logpath" D:\log\MongoDBLogs\mongodb.log "or" D:\Program Files\mongodb2.6\bin\mongod.exe "--config" D:\Program Files\mongodb2.6\mongod.cfg "; This is the trouble, it is to add MongoDB to the Windows service, the specific way to create:
Run cmd with the administrator and execute the command:
"D:\Program files\mongodb2.6\bin\mongod.exe"--config "D:\Program files\mongodb2.6\mongod.cfg"--install-- ServiceName MongoDB
This creates a service called MongoDB, and the next step is to start the service with: net start MongoDB and stop the service: net stop MongoDB;
PS: The way the creation of the official website (http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/) always fails, the service does not get up.
Note: When creating a new service using the--config method, if the contents of the Mongod.cfg file are as follows (the path is included by ""):
Logpath= "D:\log\MongoDBLogs\MongoDB.log"
Dbpath= "D:\ProgramData\MongoDB"
When you create a service, you may get an error:
2014-09-04t22:18:52.935+0800
2014-09-04t22:18:52.937+0800 warning:32-bit servers don ' t has journaling enabled by default. Please use the--journal if you want durability.
2014-09-04t22:18:52.938+0800
2014-09-04t22:18:52.938+0800 severe:failed Global Initialization:filenotopen Failed to open "" D:\log\MongoDBLogs\ MongoDB.log ""
This is because when the service is created, you will add "" to the road, so the way of the configuration does not need to use "" to include the road!
Note: The service created by the administrator just now (and only the administrator can create the service) is used by the administrator to run both commands: net start MongoDB and net stop MongoDB.
If you want ordinary users also have execute permissions, you can enter: management tools, services, find MongoDB service, start, if not, then run as Administrator: management tools and services, and then start the service, or an administrator run cmd, with net start MongoDB Startup service is also available.