![]() ![]() # please notice the credentials must be added to the 'admin' database because the 'local' database is not synchronized and can't receive user credentials # To login with such user, the connection string should be # This syntax requires mongodb 2.6+ and pymongo 2. The following operation adds a user myTester to the test database who has the readWrite role in the test database as well as the read role in the reporting database. You can assign any built-in roles or user-defined roles to the users. ![]() This user can administrate user and roles such as: create users, grant or revoke roles from users, and create or modify customs roles. After authenticating as the user administrator, use the db.createUser() method to create additional users. This is useful for oplog access (MONGO_OPLOG_URL). As per MongoDB BOL Enable Auth With access control enabled, ensure you have a user with userAdmin or userAdminAnyDatabase role in the admin database. Make sure the MongoDB server has been started (by. mongo yourhost:yourport/db1 -u myuser -authenticationDatabase admin -p. Question: Use the following steps to create users accounts in the admin and test databases in MongoDB: 1. Taking the example for the cli, your command line should look something like this. user name: sec. mongodb_user : database : burgers name : bob state : absent # Define more users with various specific roles (if not defined, no roles is assigned, and the user will be added via pre mongo 2.2 style) - mongodb_user : database : burgers name : ben password : 12345 roles : read state : present - mongodb_user : database : burgers name : jim password : 12345 roles : readWrite,dbAdmin,userAdmin state : present - mongodb_user : database : burgers name : joe password : 12345 roles : readWriteAnyDatabase state : present # add a user to database in a replica set, the primary server is automatically discovered and written to - mongodb_user : database : burgers name : bob replica_set : belcher password : 12345 roles : readWriteAnyDatabase state : present # add a user 'oplog_reader' with read only access to the 'local' database on the replica_set 'belcher'. Users can basically be saved in any database, which is why you can provide -authenticationDatabase on the command line tools, for example. How to create a user and grant him read-only access for all databases available in. mongodb_user : database : burgers name : bob password : 12345 state : present # Create a database user via SSL (MongoDB must be compiled with the SSL option and configured properly) - mongodb_user : database : burgers name : bob password : 12345 state : present ssl : True # Delete 'burgers' database user with name 'bob'. # Create 'burgers' database user with name 'bob' and password '12345'.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |