Create a MongoDB Database User
How to create a new MongoDB database user in less than one minute with ScaleGrid MongoDB as a Service
Easily create new users for your database in a few simple clicks through our fully managed MongoDB hosting platform.
How to Create a New User for Your MongoDB Database
- Log into the ScaleGrid console, or create a free 7-day trial.
Create a MongoDB Cluster beforehand
If you haven't already, you must first create a MongoDB cluster before adding users to your database.
- Create a new user with appropriate permissions for client access. The roles you choose to assign to the user will depend on your exact use-case.
Create a new user
We do not recommend connecting to your MongoDB deployment using the “admin” user that ScaleGrid provides by default. Instead, create a new user.
Most common types of users that need to be created on MongoDB are:
- Database Specific Users - Users who have single database specific roles assigned to them.
- All Database Users - Users who have All-Database roles assigned to them
Database Specific Users
Here are the steps to create simple, per-database, read-write or read-only MongoDB users:
- Log into the ScaleGrid console.
- Navigate to your MongoDB Cluster Details page.
- Click on the Databases tab.
- Then, click on the Manage button beside the database you want to create the user on:
- Select the Users tab and click on the New User button:
- Fill in the new user’s name and password, then select its role and click Create:
All Database Users
Users created on the admin database with All-Database roles provide privileges which apply to all non-system databases of the deployment. For this example, we will create a new user who has read-write access to any database on the cluster.
You can use the ScaleGrid web-shell available on the Admin tab to create such a user:
- Log into the ScaleGrid console.
- Navigate to your MongoDB Cluster Details page.
- Click on the Admin tab, and stay on the Web Shell tab on the left:
- On the MongoDB web-shell, type in the create new user command as shown in the text box below and represented in the image above:
use admin
db.createUser({ user: "dbuser", pwd: "VeryCleverPassword", roles: ["readWriteAnyDatabase"] })
For creating users with more advanced roles and permissions, refer to these resources:
Updated 23 days ago