Programster's Blog

Tutorials focusing on Linux, programming, and open-source

MongoDB 3.x - Create Users

MongoDB 3 has a different way to create users compared to version 2.x. Now we need to use createUser rather than addUser.

Enter the console

mongo

Create a user on a database

use [database name]
db.createUser(
   {
     user: "[username]",
     pwd: "[plaintext password]",
     roles: [ ]
   }
)

Read here to learn more about roles.

References

Last updated: 9th January 2023
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch