Create a Database User for MongoDB® with ScaleGrid
How to create a new database user for MongoDB® in less than one minute with ScaleGrid's DBaaS.
Easily create new users for your database in a few simple clicks through our fully managed hosting platform.
How to Create a New User for Your 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 cluster for MongoDB® before adding users to your database.
- Create a new user with appropriate permissions for client access. The roles you assign to the user will depend on your use case.
Create a new user
We do not recommend connecting to your ScaleGrid for MongoDB® deployment using the “admin” user that ScaleGrid provides by default. Instead, create a new user.
The 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 that apply to all non-system databases during deployment. For this example, we will create a new user with 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 about 1 month ago