Add username and password to mongoDb

We will keep you posted.

Add username and password to mongoDb

  • Open MongoShell terminal by selecting mongoDB instance created. and run this script.
db.createUser(
   {
     user: "myUser", // Replace 'myUser' with your desired username
     pwd: "myPassword", // Replace 'myPassword' with your desired password
     roles: [ { role: "readWrite", db: "myNewDatabase" } ] // Assign roles and specify the database
   }
);