First, IntroductionNoSQL databases are becoming more and more popular because of their extensibility, and using NoSQL databases can bring you more benefits .MongoDB is an open-source NoSQL database written in C + + that can be scaled to scale. This paper mainly describes the installation, configuration, and operation of MongoDB. Official website: http://www.mongodb.org
Second, download, installdownload page: Http://www.mongodb.org/downloadsI use the MongoDB2.0.6 version of Windows: Http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.6.zip after the download is done, for convenience, Rename the extracted folder to: MONGO, preferably moved to a folder without spaces, the author moved to the D:\SDK\mongodb
Third, configure the environment, start the service MongoDB needs a data folder to hold some of its files, the default path is the root directory of MongoDB disk \data\db folder, to the author's example, need to create the following path as shown in the folder: D:\data\db(db folder must also exist, otherwise start Mongodb\bin\mongod.exe will be error)
To start the MongoDB server just double-click on Mongodb\bin\mongod.exe and MongoDB runs on27017 ports. If you want to specify the data directory, for example, if you want to specify a directory as a: D:\sdk\MongoDB\data\db directory, you can specify the path by running Mongod.exe in the command line mode:
[HTML]View Plaincopy
- D:\sdk\MongoDB\bin>mongod--dbpath D:\sdk\MongoDB\data
For convenience, you can also start a mongod server for, and create a batch process.
Four, connect MongoDB, save data, query data run Mongodb\bin\mongo.exe Save 2 data:
[Plain]View Plaincopy
- Db.test.save ({a:1});
- Db.test.save ({uid:1,uname: "Siuon", age:21});
Enquiry: Db.test.find ();
Configure the Windows service for MongoDB while setting up the log files. 1. Create the directory and file where the log files are stored: D:\sdk\MongoDB\logD:\sdk\MongoDB\log\mongod.log2. Create a profile for the MongoDB database: mongod.cfg (stored as a key-value pair), this file specifies the port number that the service starts, the maximum connection, and so on. For details, please refer to the official documentation: MONGOD.CFG description of the randomly written configuration file:
3. Create a Windows service (run cmd as Administrator) The following command specifies the location of the database file, the configuration file, and the log file
[Plain]View Plaincopy
- 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
[Plain]View Plaincopy
- D:\sdk\mongodb\bin>net Start MongoDB
5. Stop MongoDB
[Plain]View Plaincopy
- D:\sdk\mongodb\bin>net Stop MongoDB
6. Delete the MongoDB Windows service
[Plain]View Plaincopy
- D:\sdk\mongodb\bin>mongod.exe--remove
Share one more point: if your MongoDB service always fails to start or restarts repeatedly after startup, check if there is a file named "Mongod.lock" in the Data directory , delete it if it exists, and then restart the service. This is usually due to the fact that the MongoDB service is not shutting down properly.
Original link:
http://blog.csdn.net/xiaochunyong/article/details/7730841
Getting Started with MongoDB (NoSQL)