Mongo Create a user as admin for any database raise an error
The '...AnyDatabase' roles should be added to the admin database for the user:

use admin
db.createUser({ user: "mongoadmin" , pwd: "mongoadmin", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})


Any database:


Database User Roles
Database Administration Roles


Admin database:


Cluster Administration Roles
Backup and Restoration Roles
All-Database Roles


Extra: To give different roles on different database and admin:

db.createUser({user:"replSetManager",pwd:"password",roles:[{role:"clusterManager",db:"admin"},{role:"dbOwner", db:"adminsblog"},{role:"readWrite", db:"departmentblog"},{role:"read", db:"otherblog"}]})