I. Introduction nosql databases are becoming increasingly popular due to their scalability. Using nosql databases can bring you more benefits, mongoDB is an open-source, scalable nosql database written in C ++. This article describes how to install, configure, and run MongoDB. Official Website: http://www.mongodb.org 2, download, install download page: http://www.mongodb.org/downloadspen use mongodb2.0.6 Windows Version: exist (DB folder must also exist, otherwise start MongoDB \ bin \ mongod.exe will report an error) to start the MongoDB server, double-click Mong. ODB \ bin \ mongod.exe. MongoDB runs on port 27017. If you want to specify the data directory, for example, to specify the Directory D: \ SDK \ MongoDB \ data \ dbdirectory, you can run mongod.exe in a command line and specify the path at the same time:
D:\sdk\MongoDB\bin>mongod --dbpath D:\sdk\MongoDB\data
For convenience, you can also create a batch for and start the mongod server.
4. Connect to MongoDB, save data, and query data. Run MongoDB \ bin \ cmd.exe to save two pieces of data:
db.test.save({a:1});db.test.save({uid:1,uname:"Siuon",age:21});
Query: DB. Test. Find (); 5. Configure MongoDB as a Windows service and set log files. 1. Create a directory for storing log files and a file: D: \ SDK \ MongoDB \ log \ mongod. log2. Create a configuration file for the MongoDB Database: mongod. CFG (stores the configuration as a key-Value Pair). You can use this file to specify the port number and maximum connection for the service to start. For more information, see the official document mongod. CFG description configuration file: 3. Create a Windows Service (run cmd as an administrator) and run the following command to specify the database file storage location, configuration file, and log file.
D:\sdk\MongoDB\bin>mongod.exe --dbpath D:\sdk\MongoDB\data -config D:\sdk\MongoDB\mongod.cfg --logpath D:\sdk\MongoDB\log\mongdb.log --install
4. Start MongoDB
D:\sdk\MongoDB\bin>net start MongoDB
5. Stop MongoDB
D:\sdk\MongoDB\bin>net stop MongoDB
6. Delete the MongoDB Windows Service
D:\sdk\MongoDB\bin>mongod.exe --remove
For more information, see "mongod." In the data directory. lock file, delete it if it exists, and then restart the service. This is usually because the MongoDB service is not properly closed.