Each MongoDB library can have many users, only to open the user and have access to the library operation permissions to read and write operations, MONGODB security mechanism is: 1, first to establish a super user, can be authenticated by the super user and then create the corresponding library user target: 1, create a super user to manage ( Include create new user) 2, Super User authentication and then create a normal user to read and write the corresponding database version:> db.version () 3.4.71, using the Admin database > Use adminswitched to DB admin> show Collections second, create Superuser > Db.createuser ({User: ' admin ', pwd: ' 123 ', roles:[' root '}) successfully added User: {"user": " Admin "," Roles ": [" Root "]} third, view User rights > Db.system.users.find ()
Iv. MongoDB open authentication Test Super User # vi/usr/local/mongodb/mongodb.conf
Add auth = True Restart Service v. Test superuser authentication [[email protected] bin]# ./mongo> use adminswitched to DB admin> db.auth ("admin", "123") Note: Certification must also be the first use of the admin before the certification of six, in the AA database to create a normal user > Application aaswitched to DB AA > Db.createuser ({User: ' Test ', pwd: ' 123 ', roles:[' ReadWrite '}) successfully added User: {"user": "Test", "Roles": ["ReadWrite"]}
Test Normal user > Use aaswitched to DB aa> db.auth (' Test ', ' 123 ') 1
Summary: Currently MONGODB authentication of other roles do not understand, the latter need to refuel understanding MongoDB security and authentication
5. MongoDB Learning Security and authentication