Creating a Database Administrator Account

You create a database administrator account by executing the addUser method in the MongoDB shell to access the admin database. Then you add a user with readWriteAny-Database, dbAdminAnyDatabase, and clusterAdmin rights. This gives that user the ability to access all databases in the system, create new databases, and manage MongoDB clusters and replicas. The following example creates a database administrator named dbadmin:

use admindb.addUser( { user: "dbadmin",    pwd: "test",    roles: [ "readWriteAnyDatabase", "dbAdminAnyDatabase", "clusterAdmin" ] } )

You can then use that user in the MongoDB shell to administer databases. Once you have created the new administrator account, ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.