Install mongoDB in windows (decompress version) to close the service tutorial. Decompress mongodb

Source: Internet
Author: User
Tags install mongodb

Install mongoDB in windows (decompress version) to close the service tutorial. Decompress mongodb

I am going to put the database on disk D, so I created a mongoDB folder under disk D, and created the mongoDB folder and mongoDBdata folder respectively under it, which are used to store data

Decompress the downloaded zip package to d: \ mongoDB,

The following directory is displayed:

Open cmd. Go to the bin directory.

Enter mongod.exe -- dbpath D: \ MonoDB \ mongoDBdata and press Enter.

The data storage location is set here, that is, the folder created just now

Press enter to see

MongoDB uses port 27017 by default.

Set the environment variable (although theoretically not set, it is set for convenience)

D: \ MongoDB \ mongoDB \ bin Add the path to the environment variable path

Enter the following statement in cmd:

Mongod-help

If a large amount of help document information is output, the setting is successful.

Open the page and you will see the same interface as you just arrived.

This is basically done.

Of course, we can use help information to create bat to process files.

If you create a text file, enter

Mongod -- dbpath D: \ MongoDB \ mongoDBdata

Save it as a batch file suffixed with. bat

This is a file for enabling the Service. You can click this file to enable the Service directly, without the need to use cmd to enter the corresponding directory.

Note that there is a cmd.exe program in the D: \ MongoDB \ mongoDB \ bindirectory to connect to mongo. if the service mentioned above is not enabled, then you will find that running this program will flash, or the following

Error: 10061 error message indicating a connection failure due to the active rejection of the target computer

At this time, you only need to restart the previous service and then run the program to succeed.

Of course, cmd.exe can also create its own running script, as shown below:

Create a file xxx. bat (which can be customized by xxx)

Content input:

Mongo localhost: 27017

Save and start again.

Here, localhost can be changed to another type, such as its own local ip address.

By default, mongo is started as a test user. We can modify the above file.

Mongo localhost: 27017/admin

Use the Administrator identity to open the command window (Be sure to use the Administrator identity; otherwise, access may be denied. If you do not open the window, use Baidu twice), go to the bin directory of MongoDB, and execute the following command:

Mongod -- dbpath E: \ MongoDB \ data \ db -- logpath E: \ MongoDB \ data \ log \ mongodb. log -- install -- serviceName "MongoDB"

If you see the following results, it means that the creation is successful (wondering why there are no prompts ):

Open the Windows service management tool and you can see that the service has been successfully created:

Use the net start MongoDB command to start, as shown below:

Or start it manually using Windows Management tools:

4.4 Stop Service

Use the net stop MongoDB command to stop the instance, as shown below:

4.5 delete a service

1) Non-configuration files are used during creation.

Before deleting a service, stop the service and then delete it. The DELETE command is as follows:

Mongod -- dbpathE: \ MongoDB \ data \ db -- logpath E: \ MongoDB \ data \ log \ mongodb. log -- remove -- serviceName "MongoDB"

The same installation, but the installation is replaced with the remove

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.