Install MongoDB on Windows

Source: Internet
Author: User
Tags install mongodb

Install MongoDB on Windows

First, go to the official MongoDB website. Next, we can observe that the folder contains the following files:

As you can see, MongoDB is very simple, with only 10 files. Next, create a directory for storing database files, which is set to c: \ mymongodb. Then you can start MongoDB in the command line mode and run the following command:

C: \ mongodb-win32-1.8.1 \ bin> mongod -- dbpath "C: \ mymongodb"
When the following message is displayed, it indicates that MongoDB has been successfully started.

Fri APR 29 17:15:34 [initandlisten] MongoDB starting:
PID = 5280 Port = 27017 dbpath = c: \ mymongodb 32-bi
...
Fri APR 29 17:15:34 [initandlisten] waiting for connectionon port 27017
Fri APR 29 17:15:34 [websvr] Web Admin Interface listening on port 28017

In the above information, we noticed that MongoDB listened to the connection from the client on port 27017, while on port 28017, the Web interface management tool was enabled, so we can use http: // visit localhost: 28017. You can see the following interface:


▲Click to view the large image

Next, we will learn how to install MongoDB as a service in windows. First, under MongoDB, we can use the-help option to view the help commands as follows:

C: \ MongoDB \ bin> mongod -- Help
 
Windows Service Control Manager options:
-- Install MongoDB Service
-- Remove MongoDB Service
-- Reinstall MongoDB Service (equivilant of mongod
-- Remove followed by mongod -- install)
-- Servicename Arg Windows Service name
-- Servicedisplayname Arg Windows Service display name
-- Servicedescription Arg Windows Service Description
-- Serviceuser Arg user name service executes
-- Servicepassword Arg password used to authenticate serviceuser

We can see that the -- install and-Remove parameters are exactly what we need. Therefore, the command to install MongoDB into a Windows service is as follows:

Mongod -- dbpath "C: \ mymongodb" -- logpath "C: \ mymongodb \ logs.txt" -- install -- servicename "MongoDB"

In the preceding command line, use the-dbpath parameter to specify the database directory, -- logpath indicates the directory where logs are stored, and-servicename indicates that, the name of the installed Service is MongoDB. The following prompt is displayed after running:

All output going to: C: \ mymongodb \ logs.txt
Creating service MongoDB.
Service creation successful.
Service can be started from the command line via 'net start "MongoDB "'.

In addition, you can view the service in the Windows Control Panel. The command to uninstall the service is also very simple, as follows:

Mongod -- remove -- servicename "MongoDB"
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.