MongoDB is installed under Windows with the Auth mode enabled service

Source: Internet
Author: User
Tags auth create mongodb mongodb version robomongo

First, download the installation

1, go to the official website to download the MongoDB version for their own computer to download MongoDB

  

2. Installing MongoDB

Installation or relatively simple, follow the step by step to go down on it.

    

3. Start MONGODDB

After the installation is complete, locate your installation directory and open it.

    

Create a new Data folder under this directory to hold the database. Create a new log directory to hold the log, and add the Log.log file to the log directory to hold the log.

Next open the cmd command, and note that you want to open it with administrator privileges.

    

Locate the directory in the Bin folder under MongoDB. Enter Mongod--dbpath G:\SoftInstall\MongoDB\data Note: G:\SoftInstall\MongoDB\data is the path to your local newly created data file.

    

The output above indicates that it has been installed and started successfully. But we started with the Windows service, which makes it easier to use later. Now close the cmd Command window, and then use the administrator to hit a new cmd command window. Or, locate the Bin folder under the MongoDB installation directory first.

We need to specify his log path at the start of the service mode. Enter the installation service command as follows: SC create MongoDB binpath= "G:\SoftInstall\MongoDB\bin\mongod.exe--dbpath G:\SoftInstall\MongoDB\data-- LogPath G:\SoftInstall\MongoDB\log\log.log--logappend--service "

--dbpath refers to the path of the database, just the newly created data path,--logpath refers to the path of the log file, just the new. log file.

  

Start service: net start MongoDB

This is a service that is registered and started in a way that is not auth, but it is not safe to start the service in a auth way, and we will now create a new administrator user to prepare to start the service in Auth mode later.

Input command: MONGO draw the Red line this part is I do more operation, no tube.

Then enter the command in turn:

Use admin


Db.createuser ({User: "Yjq", pwd: "123456", roles:[{"role": "Useradmin", "db": "admin"},{"role": "Root", "db": "Admin"},{ "Role": "Useradminanydatabase", "db": "Admin"}]})

Be careful to change the corresponding user and pwd to the value you want.

Authorization to Account: Db.auth ("Yjq", "123456")

At this end a simple account authorization is over. Description of permissions See MongoDB 3.X User Rights control

Exit Current Operation Input exit

The service is then uninstalled and started in a auth manner. Enter the following command in turn:

1, uninstall the original installation of services: SC Delete MongoDB

2. Start the service in auth mode: sc create MongoDB binpath= "G:\SoftInstall\MongoDB\bin\mongod.exe--dbpath G:\SoftInstall\MongoDB\ Data--logpath G:\SoftInstall\MongoDB\log\log.log--logappend--auth--service "

Maybe everything's not going so well. "The specified service has been marked for deletion. "Prompt.

Don't panic, open the Service Management page,

Find MongoDB, right-click Stop, and then you will find that this list does not have it anymore. Just appeared "The specified service has been marked for deletion." The reason for this is that the service is still present on the service Management page and needs to be refreshed when executing the delete command.

Continue to execute SC create MongoDB binpath= "G:\SoftInstall\MongoDB\bin\mongod.exe--dbpath G:\SoftInstall\MongoDB\data--logpath G : \softinstall\mongodb\log\log.log--logappend--auth--service "

After execution, enter net start MongoDB

Enter the instruction MONGO and then continue typing show DBS

No permissions were found because we did not log in with a privileged account. Then we exit the login.

Enter exit exit, and then enter Mongo-u yjq-p 123456 localhost:27017/admin

-U and-P are followed by their own account and password respectively. Will find the login successful, and then you can do some of the appropriate action

Second, the MongoDB visualization tool

I chose Robomongo click to download Robomongo

After the download is complete, the corresponding operation and installation can be done.

Click Create, then enter the account password you just created in authentication, click Save and Connect

Here, MongoDB installation and visualization tool installation is over, if you encounter any problems during the installation process, welcome to discuss

MongoDB installation under Windows and enable services in Auth mode

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.