[DOCS-9111] Create user Created: 07/Oct/16  Updated: 03/Nov/17  Resolved: 07/Oct/16

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.com/master/tutorial/enable-authentication/
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36
Screen Resolution: 1366 x 768


Participants:
Days since reply: 7 years, 18 weeks, 5 days ago

 Description   

when create use on version 3.2.10 on ubuntu OS.
throw exception:
TypeError: Property 'createUser' of object admin is not a function.

while useing addUser() is working.
but failed with db.auth() event I create user with addUser() function;



 Comments   
Comment by Ravind Kumar (Inactive) [ 07/Oct/16 ]

Thank you for filing a DOCS ticket.

I was not able to reproduce your issue on MongoDB 3.2.10. addUser() is deprecated, and db.createUser() is the correct method for adding a user to a database.

> use admin
switched to db admin
> db.createUser(
...   {
...     user: "myUserAdmin",
...     pwd: "abc123",
...     roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
...   }
... )
Successfully added user: {
	"user" : "myUserAdmin",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	]
}
> db.getUsers()
[
	{
		"_id" : "admin.myUserAdmin",
		"user" : "myUserAdmin",
		"db" : "admin",
		"roles" : [
			{
				"role" : "userAdminAnyDatabase",
				"db" : "admin"
			}
		]
	}
]

I was then able to follow the steps in the tutorial to restart the mongod with authentication enabled and auth as the user.

Please create a post on the MongoDB Google Group for support. Depending on the outcome of your support ticket, more specific documentation improvements may be possible.

Generated at Thu Feb 08 07:57:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.