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

  1. Log into the ScaleGrid console, or create a free 30-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.

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

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

  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