I. Introduction
NoSQL databases become more and more popular because of their scalability. Using NoSQL databases can bring you more benefits. MongoDB is an open-source NoSQL database compiled in C ++ with high scalability. This article describes how to install, configure, and run MongoDB. Http://www.mongodb.org
Ii. Download and install
Download Page: http://www.mongodb.org/downloads
The author uses MongoDB2.0.6 Windows Version: http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.6.zip
After the download is complete, decompress the package. For convenience, rename the decompressed folder to mongo. It is best to move it to a folder without spaces. I moved it to D: \ sdk \ MongoDB.
3. Configure the environment and start the service
MongoDB needs a data folder to store some of its files. The default path is the \ data \ db folder under the root directory of the disk where MongoDB is located. For example, you need to create a folder shown in the following path:
D: \ data \ db (the db folder must also exist; otherwise, an error will be reported when MongoDB \ bin \ mongod.exe is started)
To start the MongoDB server, you only need to double-click MongoDB \ 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 ();