How the MongoDB database installs, configures MongoDB

Source: Internet
Author: User
Tags connect to mongodb server how to connect to mongodb how to install mongodb on windows install mongodb mongodb server

this blog in the most concise way to record the blogger in the process of tossing mongodb drops, including the download MongoDB, configuration environment variables, how to start the MongoDB server, how to connect MongoDB servers, and how to connect to MongoDB servers.

1. Download MongoDB

Official: Http://www.mongodb.org/downloads

This machine is a Windows 7 32-bit, so the download is mongodb-win32-i386-2.6.1.zip, and subsequent routines are based on that version of the database.

2. Configure Environment Variables

Unzip the Mongodb-win32-i386-2.6.1.zip file to E:\, and rename the mongodb-win32-i386-2.6.1 folder to MongoDB, directory structure such as

and configure the environment variable in System setup Path = E:\mongodb\bin; ( easy to use the MOGODB command directly on the command line )

3. Configure the MongoDB database

Create a mongo.config configuration file, configure the DBPath (Database storage path) and LogPath (log file storage path) for the MongoDB database, and themongo.config file contents are as follows:

You can also use the--dbpath option and the--logpath option to configure the path.

# #store Data heredbpath=e:\mongodb\data # #all output Go Herelogpath=e:\mongodb\log\mongo.log

Special tips:

Because the DBPath path is E:\mongodb\data, and this folder does not exist by default, it needs to be created manually , otherwise you will not be prompted to find the folder when you start the MongoDB server, and you need to manually create a E:\mongodb\log folder is used to save the log.

4. Start the MongoDB serverUse Mongod.exe--config E:\mongodb\mongo.config to start the MongoDB server. The--config option indicates that the server is configured with information from the E:\mongodb\mongo.config configuration file at startup.

5. Connect to MongoDB server

Use Mongo.exe to connect a MongoDB server that is already started. (If the 4th step server does not start successfully, the connection to the MongoDB server will be reported in the 7th Step exception Error!) )

After successful startup, enter the MongoDB shell command line, we can access the database on the mongodb shell command line , and we have already performed CRUD operations on the database.


6. Add MongoDB to winodows service

Window service to start the MongoDB server. In fact, to do the 5th step, we have completed the installation of MONGODB data has been configured to directly start to tinker with MongoDB crud command

, but each time through the 4th step to add configuration and start the inevitable trouble, this is the 6th step to add the MongoDB to the window service, implemented by starting the service to start the MongoDB service

Manager

1) Add MongoDB to Windows service so that the MongoDB service starts automatically when you configure the system to start through window services. After the configuration is successful, you can see the service in the services in Control Panel, as shown in:

c:\users\administrator> mongod--config D:\mongodb\mongo.config--install

2) Start MongoDB Service

c:\users\administrator>net start MongoDB

3) Stop MongoDB Service

c:\users\administrator>net stop MongoDB

4) Remove the MongoDB service from the Windows service

c:\users\administrator>Mongod--remove

5) See more Configuration command options via Mongod--help.

c:\users\administrator>Mongod--help

--install Install MongoDB Service
--remove Remove MongoDB Service
7. Exception:

warning:failed to connect to 127.0.0.1:27017, reason:errno:10061

Indicates that the MONDODB server was not started or failed to start the server;

8. Reference:

How to Install MongoDB on Windows ( recommended )

Install MongoDB on Windows

MongoDB configuration options

9. You may be interested in:Reprint Please specify source: http://blog.csdn.net/andie_guo/article/details/26068711, thank you!
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.