I can't believe that there is no simple example for this. I keep reading different versions everywhere.
mongo --port 27017 -u "admin" -p "mypass" --authenticationDatabase "mydb"
use mydb
db.createUser(
{
user: "normal",
pwd: "anotherpass",
roles: [ { role: "readWriteAnyDatabase", db: "mydb" } ]
}
)
I get:
Error: couldn't add user: No role named readWriteAnyDatabase