MongoDB Identity Verification

Source: Internet
Author: User
Tags auth

Super Admin

For more secure access to MongoDB, visitors are required to provide a user name and password, so users need to be created in MongoDB

Using the role-user-database security management method

Common system roles are as follows:
Root: Only available in the Admin database, super account, super privilege
READ: Allows the user to read the specified database
ReadWrite: Allows the user to read and write to the specified database

Create a Super Admin user
Use admindb.createuser ({    User:'admin',    pwd:'  123',    roles:[{role:'root', DB:'  Admin'}]})
The Ubuntu Environment

Modify /etc/mongodb.conf , setauth=true

sudo vim/etc/mongodb.conf

/etc/mongodb.confThere is a configuration in the file auth=true , just delete the previous "#".

Restart MongoDB
Service MongoDB Stop  # Stop MongoDB Service (because MongoDB is self-booting with boot)# Open MongoDB service



You are prompted that an unauthorized administrator executes the command, and obviously the security verification check is turned on successfully, and you mongo admin -u root -p 123456 should connect this way:

Or you can also verify this (provided that the user must enter the corresponding database, the 1 represents success):



Under the WinDOS environment
      • After creating the administrator:
      • Then restart mongodb , but you must add the --auth option to modify the contents of the. bat file to:mongod --auth --dbpath D:\软件安装\MongoDB\data\db

MongoDB Identity Verification

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.