Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "admin" database in mongodb?

Tags:

mongodb

admin

I was practicing ont mongodb documentation : https://docs.mongodb.com/manual/tutorial/enable-authentication/

and I can't figure out if the "admin" database in the example is just a database created for the tutorial or if it is a built-in database made specifically for managing admin users.

Thanks in advance.

like image 281
Micawber Avatar asked Jan 14 '18 20:01

Micawber


3 Answers

The main purpose of this admin database is to store system collections and user authentication and authorization data, which includes the administrator and user's usernames, passwords, and roles. Access is limited to only to administrators, who have the ability to create, update, and delete users and assign roles.

like image 82
Sushant Pimple Avatar answered Oct 23 '22 04:10

Sushant Pimple


When you create a database in MongoDB you don’t have authentication enabled, the user has all the privileges and roles over that database, you even have access to the database remotely if the firewall doesn’t have port 27017 blocked.

There are two special databases admin and local, users of these databases can perform operations such as those mentioned in the document on other databases to which they have access. In a development environment it is convenient not to worry about users and passwords, however, when users interact with the database remotely on an application, it is essential to activate user authentication.

like image 27
D Mares Avatar answered Oct 23 '22 05:10

D Mares


The admin database is built-in database. Apart from user authentication and authorization data it also includes Roles for administering the whole system rather than just a single database. These roles are mainly related to replica set and sharded cluster administrative functions.

Roles which are created in other database than admin can only include privileges that apply to its database and can only inherit from other roles in its database.

A role created in the admin database can include privileges that apply to any database or to the cluster resource, and can inherit from roles in other databases as well as the admin database.

like image 1
Wernfried Domscheit Avatar answered Oct 23 '22 05:10

Wernfried Domscheit