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

  1. 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.

  1. 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:

  1. Database Specific Users - Users who have single database specific roles assigned to them.
  2. 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:

  1. Log into the ScaleGrid console.
  2. Navigate to your MongoDB® Cluster Details page.
  3. Click on the Databases tab.
  4. Then, click on the Manage button beside the database you want to create the user on:

  1. Select the Users tab and click on the New User button:

  1. 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:

  1. Log into the ScaleGrid console.
  2. Navigate to your MongoDB® Cluster Details page.
  3. Click on the Admin tab, and stay on the Web Shell tab on the left:

  1. 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:


What’s Next

Connect to your MongoDB® deployment using the user you just created