With access control enabled, users are required to identify themselves. You have to grant a user one or more . A role grants a user to perform certain on MongoDB Show
Each application and user of a MongoDB system should map to a distinct user. This principle of access isolation facilitates access revocation and ongoing user maintenance. To ensure a system of , only grant the minimal set of privileges required to a user. PrerequisitesTo be able to create users, you need to: For routine user creation, you must possess the following permissions:
The and built-in roles provide and actions on their respective resources. ProcedureNoteThe following procedure uses authentication. For additional information on other authentication mechanisms, see 1 Using , connect to your primary or, in a sharded cluster, connect to your and authenticate as a user administrator or a user with the 2
The following step uses authentication. For additional information on other authentication mechanisms, see After authenticating as the user administrator, use the method to create additional users. You can assign any built-in roles or user-defined roles to the users. The following operation adds a user 9 database who has the role in the 9 database as well as the role in the 3 database.
TipThe method prompts you to enter the password. You can also specify your password directly as a string. We recommend to use the method to avoid the password being visible on your screen and potentially leaking the password to your shell history. The database where you create the user (in this example, 9) is that user's . Although the user authenticates to this database, the user can have roles in other databases. The user's authentication database does not limit the user's privileges.After creating the additional users, exit 3
It is not possible to switch between users in the same session. Authenticating as a different user means the session has the privileges of both authenticated users. To switch between users exit and relaunch After exiting as 2, reconnect as myTester :4 As the user
TipSee also:Manage Users and Roles Additional ExamplesUsername/Password AuthenticationThe following operation creates a user in the 3 database with the specified name, password, and roles.TipThe method prompts you to enter the password. You can also specify your password directly as a string. We recommend to use the method to avoid the password being visible on your screen and potentially leaking the password to your shell history.
Kerberos AuthenticationUsers that authenticate to MongoDB using an external authentication mechanism, such as Kerberos, must be created in the 4 database, which allows or to consult an external source for authentication.To use with 4 authentication users (Kerberos, LDAP, or x.509 users), usernames cannot be greater than 10k bytes.For Kerberos authentication, you must add the Kerberos principal as the username. You do not need to specify a password. The following operation adds the Kerberos principal 8 with read-only access to the 9 database:
TipSee also:For more information about setting up x.509 Client Certificate authentication for your MongoDB deployment, see the following tutorials: MongoDB menggunakan bahasa apa?MongoDB sendiri ditulis dengan bahasa C++ dan telah tersedia untuk berbagai jenis bahasa pemrograman. Fitur utama dari mongoDB antara lain: model document-oriented storage.
MongoDB digunakan untuk apa?3. Cocok Untuk Menampung Data yang Bervariasi
Dynamic schema membuat MongoDB cocok untuk menampung data yang bervariasi baik digunakan untuk menyimpan data yang terstruktur ataupun yang tidak terstruktur.
Kapan harus menggunakan MongoDB?Dari sisi struktur data, MongoDB cocok digunakan untuk data yang tidak terstruktur.
Apa itu Collection di MongoDB?Collection MongoDb adalah tempat kumpulan informasi data yang berbentuk dokumen. Collection dipadankan seperti tabel-tabel yang berisi data pada database SQL. Document MongoDb adalah satuan unit terkecil dalam MongoDB.
|