MongoDB set access permissions

2011-07-02  来源:本站原创  分类:Database  人气:78 

Original Address:

MongoDB has been used for a long time, MongoDB-based data storage has been no use to have permission to access (MongoDB default no permission to access restrictions), spent some time today specifically studied a bit of research results are as follows:
Note: The research results based on the Windows platform
MongoDB deployed in the machine after installing
1 Enter the command: show dbs, you will find that it has two built-in database, a name is admin, called local. local seems futile, if in the course of which found that the use of local table, hoping to remind the message, then we concentrate on the table for that admin
2 Enter the command: use admin, you will find that the DB contains a system.user under the table, Oh, yes, this table is equivalent to MsSql in the user table to hold the super-administrator, and then we go out into the add a super administrator it inside try
3 Enter the command: db.addUser ('sa', 'sa'), where I add a super administrator user, username is sa, password for sa, now that we add a super administrator, then we will go to test Next, we see no need to re-connect MongoDB prompt for user name, password, we exit to (ctrl + c)
4 Enter the command: use admin
5 Enter the command: show collections, see all the tables in the library, you will find, MongoDB does not prompt you to enter a user name and password, it is strange, how is this going on? The beginning of the article mentioned,
MongoDB default setting is no permission to access restrictions, now that so, then we first need to have permission to access it to set a limit, let's look at the results, how to set it?
6. In the registry, find MongoDB node in its ImgPath, we change it, add-auth, as follows:
"D: \ Program Files \ mongodb \ bin \ mongod"-dbpath e: \ work \ data \ mongodb \ db-logpath e: \ work \ data \ mongodb \ log-auth-service
7 Enter the command: use admin
8 Enter the command: show collections, Oh, we found it impossible to view the library under the table, the prompt: "$ err": "unauthorized db: admin lock type: -1 client:", it is clear, suggesting that there is no rights, it seems the key is here, we start MongoDB, you need to add-auth parameter, so we set the permissions to take effect, well, then we use the set just before the user name and password to access the
9 Enter the command: db.auth ('sa', 'sa'), a result of the output value of 1, indicating that the user is matched, if the user name, password wrong and they'll enter 0
10 Enter the command: show collections, Oh, the results came out, here, is also only mentioned permission settings half, and then goes on to talk, let's withdraw (ctrl + c)
11 Enter command: mongo TestDB, we try to connect a new library (whether the library exists, if does not exist, add data to the library, the library created by default), then, we would like to see the library table
12 Enter the command: show collections, Goodfellas, no authority, we created above, enter the user name, password
13 Enter command: db.auth ('sa', 'sa'), enter the result 0, the user does not exist, this next one might not understand, just in front of it created, how could it not exist? The reason is: when we separate the database access MongoDB need to have permission to access the situation, not the super administrator user name password, but the library system.user table users, note that I said here is a single access situation and what is not a separate visit to the situation? Then repeat that, now supposed to, no authority, then we try to add the library system.user users table
14 Enter command: db.addUser ('test', '111111 '), Holy crap, still do not have permission prompts, it can be supposed that the new database using the super administrator can not access, create, users do not have permission, Oh, Do not worry, now that the administrator set a super user, then it must have access to all library
15 Enter command: use admin
16 Enter command: db.auth ('sa', 'sa')
17 Enter command: use TestDB
18 Enter the command: show collections, ha ha, smooth the way, we find that the administrator can use the super-user access to other libraries, Oh, this is not the case of a single visit, not difficult to find, we are the first to enter the admin database, sub- to other library's, admin is the equivalent of a top-level officials in your area, if you are a real estate business, would like to get hold of large projects in the areas doing, you do not want to do after those senior officials, it does not work, you need They go to where the delivery point gift, and then down down to the place, you can get our hands on projects, and this statement is only personal opinion, does not mean blog park; now that works to get the hand, and begin to build up, then we will not add every brick, tile had to go and add a band of senior officials greeted it, so we have to make the legalization of this project, we have to get the relevant procedures and documents is complete, and will not be illegally built
19 Enter command: db.addUser ('test', '111111 '), we add a user to TestDB library, after each visit to the library, I use just created this user, we first exit (ctrl + c)
20 Enter command: mongo TestDB
21 Enter the command: show collections, tips do not have permission
22 Enter command: db.auth ('test', '111111 '), output 1, the user exists, the validation is successful
23 Enter the command: show collections, did not prompt me again do not have permission, congratulations, success tired ah! Breath finish, Oh Note: When you need permission to access MongoDB, if you need to see MongoDB all the libraries, we can only super-administrator privileges, enter the command show dbs to view the.

  • MongoDB set access permissions. Set user 2011-07-29

    Keywords: MongoDB set access permissions, set user MongoDB has been used for a long time, MongoDB-based data storage has been no use to have permission to access (MongoDB default no permission to access restrictions), spent some time today specifical

  • MongoDB set access permissions. Set user (rpm) 2011-04-27

    Original Address: MongoDB has been used for a long time, MongoDB-based data storage has been no use to have permission to access (MongoDB default no permission to access restrictions), spe

  • MongoDB set access permissions 2011-07-02

    Original Address: MongoDB has been used for a long time, MongoDB-based data storage has been no use to have permission to access (MongoDB default no permission to access restrictions), spe

  • Linux file and directory access permissions 2010-06-19

    1, file and directory permissions Overview Zai linux Each directory contains a file or have access, such access rights determine who can access and how to access these files and directories. By setting the permissions can be restricted from the follo

  • File or directory access permissions 2010-07-28

    Quick to understand Linux file permissions, see Permissions, important and tricky! Unix permissions concern who can read a file or directory, write to it, and execute it. Permissions are granted or withheld with a magic 3-digit number. The three digi

  • Close / restrict the user remote access permissions MYSQL 2010-10-02

    Because it involves a convenient reasons, MYSQL remote access permissions to the specified user opens, and by updating the user table in mysql database field value corresponding to that, and in the establishment of the database, give the remote acces

  • Linux File Access Permissions 2010-10-09

    4.5 of Advanced Programming in the UNIX programming has a very clear explanation for file access permissions. Here is an experiment to show the explanation. #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcn

  • Linux basic commands: chmod to change file or directory access permissions 2010-11-15

    linux commands and files and directories under the names are case-sensitive / / Move the file mv .*. swp 123.bak / / Read performance top / / shift key + "m" is based on "memory" Sort / / See the environment variable env / / Browse fil

  • IP access permissions in IIS7.0 and denial 2011-01-14

    IIS7.0 to achieve the IP access permissions and denied access restrictions need to install IP-related services, and then to the "functional view" see "IPV4 address and domain restrictions." Then we can set access rules.

  • I used the Linux command chmod - change file / directory access permissions 2011-08-03

    I used the Linux command chmod - change file / directory access permissions This link: (reproduced please indicate the source) Use Description chmod to change file or directory access permissions. Linux /

  • linux file access permissions that 2011-01-05

    To illustrate this: - | Rw-| r - | r - 1, r on behalf of readable, w that can be written, - said the owner of the file does not execute permission on file with executable permissions are indicated by x. 2, the first character is the file type (file t

  • Upload file access permissions set weblogic 2010-12-09

    in linux, weblogic uploaded files or create a directory, the default read only their own members or reading, but web access the directory, usually need to do, so you need to configure weblogic startup script to find, vi it, to increa

  • Camera Flash access permissions 2010-06-21

    <Permission android: name = "android.permission.FLASHLIGHT" android: permissionGroup = "android.permission-group.HARDWARE_CONTROLS" android: protectionLevel = "normal" android: label = "@ string / permlab_flashlight&q

  • Acquaintance MongoDB (three) - MongoDB Client Shell access 2011-06-08

    Three, MongoDB Client Access - Shell mode MongoDB is MongoDB comes with an interactive Javascript shell, used to operate and manage MongoDB interactive environment. Use ". / Mongo - help" to view the connection parameters, following from the com

  • Java MongoDB simple example 2011-07-21

    1 download MongoDB, Java Driver Download: Download: 2 Installing MongoDB View Quick Start document: You must extrac

  • Role-Based Access Control System Design 2009-04-07

    Role-Based Access Control System Design (2004-7-23 17:06:00) Source: CCW Authors: Wang Jiuhui Access Control Policy are the majority of the application system must be taken into account. In this paper, role-based access control is a new access contro

  • Apache + Tomcat integrated block access to WEB-INF directory (change) 2010-03-29

    Apache + Tomcat integration, the two main directories point to the same directory, for example / website / app, because Tomcat needs in the main directory or the next context to build a WEB-INF directory for the Tomcat, the adoption of the 8080 port

  • Design based on RBAC permissions 2010-03-29

    RBAC-based design model of competence: 1 RBAC Introduction RBAC model as is currently the most widely accepted model of competence. NIST (The National Institute of Standards and Technology, U.S. National Institute of Standards and Technology) standar

  • Java in a variety of modifier description of and access modifiers 2010-04-21

    Categories: Access modifier modifier extends the parent class class name class name implement interface name (Visit the location modifier and modifiers can be used interchangeably) Access modifier Name Description Notes public All classes can be acce

  • SVN user permissions 2009-01-17

    Svn complete installation Create the repository directory # mkdir / app1/eGroup Setting up a repository # svnadmin create / app1/eGroup Import Project # svn import / app1/TS / svn: / / / eGroup / TS / trunk-m "initial import" - u