MONGODB2.6 's rights management and 2.4 are very different, the Internet can see the basic articles are based on 2.4 below, many do not apply. After some groping finally straightened out 2.6 of the rights management, take notes.
The version I'm using is Linux 64-bit,:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.6.tgz
MongoDB does not enable rights management by default, and access does not require authentication. To turn on the Rights Management feature, increase the--auth parameter at startup.
When enabled, there are no users in the database, and the non-native Client access will prompt for errors
Can only be maintained by native login if the database does not yet have any users
Add an administrator to the database by using the following command. 2.4 and previous versions are used with the AddUser command, after 2.6 with CreateUser.
Use admin
Db.createuser ({"User": "admin",
"pwd": "admin",
"Roles": [{role: ' Useradminanydatabase ', db: ' admin '},
{role: "Dbadminanydatabase", DB: "Admin"}
]
})
It is recommended to switch to the admin library, otherwise the Admin user will be created under another library.
Once you have created the first user, you must also log on to use the database. Logging in with another shell will cause an error.
The client that was already connected is not able to operate.
At this point, you need to log in first, with Db.auth (user, password) command, return 1 for authentication pass.
db.system.users.find () or show users can query to our newly added admin user.
If the Admin user was created in a different library, such as test, then the user who was found should be like this
The differences are in both the _ID and DB fields. When used differently, the database that is validated when the user logs on is displayed. Logging in under the Admin Library is not allowed at this time, you must first switch to the test library.
Once logged in, you can manage any database and user.
Not to be continued ...
?
?
?
MongoDB 2.6.6 Rights Management