Getting started with MongoDB

Source: Internet
Author: User
Tags mongodb server mongodb windows
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.