MongoDB Install and manage users

Source: Internet
Author: User


MongoDB has two roles 1 dedicated to managing User 2 Management Operations 1 MongoDB installation from the official Web download MongoDB MSI file (http://www.mongodb.org/downloads), the version I currently use is 3.0.3 (window). Double-click the MSI file installation, after the installation is complete, there are the following files if you want to start quickly, you can put C:\mongodb\bin into the environment variable path. 2 Start MongoDB after the first successful installation, MongoDB does not have any users, so to start in a non-validating way, so that you can have permission to increase the user command line:Mongod--dbpath=/opt/mongodata/data mongod Default port of 270173 connect MongoDB on new command line enter MONGO connection MongoDB default connection local 127.0.0.1 Service 4 Create Admin user use ADM In Switch to admin library
Db.createuser (  {    User: "Siteuseradmin",    pwd: "Password",    roles: [{role: "Useradminanydatabase", DB: "Admin"}]  })
Create a system administrator account Siteuseradmin
Db.createuser (  {    User: "Testuseradmin",    pwd: "Password",    roles: [{role: "Useradmin", DB: "Test"}]< c10/>})
Create an administrator account for a separate database testuseradmin 5 Create a normal user MongoDB in the above operation do not need to verify permissions, after creating the system administrator can restart the service (Turn on permission authentication) to open the command:Mongod--dbpath=/opt/mongodata/data--auth--auth Enable authentication command use test to switch to test library Db.auth (' testuseradmin ', ' password ') to verify user Db.createuser (
{
User: "User",
PWD: "123456",
Roles: [
{role: "ReadWrite", DB: "Test"}

]
}
Create user password 123456 The role has read and write permissions in the test library. Read reads, write writes ReadWrite for read-write Db.auth (' user ', ' 123456 ') to verify that the test library can be manipulated underneath the new user

MongoDB Install and manage users

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.