Preface:As the Columnstore concept matures, more and more developers are embracing mongodb,hbase, a large-storage, distributed, Columnstore database. In particular, MongoDB's rapid construction, the rapid use of features, so that it gets more people's favor. I mainly through the official website description for MongoDB permissions configuration to do a test and practice.
Step1: No authentication start Mongod servicemongod--port 27017--dbpath/data/db1
step2: Client MONGO no password connection and set Superuser (for admin login)MONGO--port 27017Use Admindb.createuser (
{
User: "Myuseradmin",
pwd: "abc123",
roles: [{role: ' Useradminanydatabase ', db: ' admin '}]
})
Step3: There is a validation start Mongod servicemongod--auth--port 27017--dbpath/data/db1
step4: Administrator MONGO new user after login, assign permissionsMONGO--port 27017-u "Myuseradmin"-P "abc123"--authenticationdatabase "admin"Use Testdb.createuser (
{
User: "Mytester",
pwd: "xyz123",
roles: [{role: ' ReadWrite ', DB: ' Test '},
{role: "read", DB: "Reporting"}]
})
STEP5: Authorized user to log in and manipulate the table MONGO--port 27017-u "Mytester"-P "xyz123"--authenticationdatabase "test"Db.foo.insert ({x:1, y:1})Note: When no access is granted, the following error will be reported
Reference: https://docs.mongodb.com/v3.2/tutorial/enable-authentication/
post-language:The above is only for the simple management of MongoDB, not to be directly connected to the port by the outside world. But more systematic rights management also please refer to the official website description https://docs.mongodb.com/v3.2/tutorial/manage-users-and-roles/
MongoDB Add Rights Management