Create a database user with roles.
Section: Users and roles
Create a user
javascript
javascript
use admin
db.createUser({
user: "appuser",
pwd: "strong-password",
roles: [{ role: "readWrite", db: "appdb" }]
})Explanation
Create users in the appropriate database, often `admin` for centralized management.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Users and roles