MongoDB permission verification (key: Mongo; MongoDB; security verification; permission)

Source: Internet
Author: User

 

First, I need to delete the previously created Service tat.

SC Delete "MongoDB"

Re-create the service and add the -- auth Parameter

D: \ MongoDB> mongod -- dbpath D: \ MongoDB \ data -- logpath D: \ MongoDB \ log \ MongoDB. log -- logappend -- servicename MongoDB -- auth -- install
All output going to: D: \ MongoDB \ log \ MongoDB. Log
Creating service MongoDB.
Service creation successful.
Service can be started from the command line via 'net start "MongoDB "'.

When you start Mongo again, the system will prompt that you do not have the permission.

> Show users
Wed Aug 17 09:53:30 uncaught exception: Error :{
"$ Err": "unauthorized DB: Admin lock type:-1 client: 127.0.0.1 ",
"Code": 10057
}

You can log in with the-u-p Parameter-> Mongo [database name]-U [user name]-P

D: \ MongoDB> Mongo admin-u admin-P
MongoDB shell version: 1.8.2
Enter password:
Connecting to: Admin

Of course. Do not forget to create a user first. The user in the admin database is global.

Use [database]

DB. adduser ('admin', 'pwd ')

Show users

To create a read-only user:

DB. adduser ('rousr', 'pwd', true)

 

Here is the security verification in C:

Link string format: MongoDB: // [Username: password @] hostname [: Port] [/[database] [? Options]

You just need to change the link string of the previous example to "MongoDB: // uname: Pwd @ localhost ".

... My previous password contains @, so... Tat

Changing the password is the same as creating a USER command.

DB. adduser ('admin', 'newpwd ')

 

For other Common commands, click "-".
Common commands

 

Http://hi.baidu.com/pappercut/blog/item/4fc5281fd2873ed2a7866997.html

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.