Mongo createUser command requires authentication

436 Views Asked by At

I have installed Mongo 4.4 on Ubuntu 20. Im trying to create an admin user. But everytime I run the createUser command I get the following error. enter image description here

How can I overcome this? Thank you!

2

There are 2 best solutions below

0
dododo On

call: db.auth("your username", "your password")

0
Forhad Hossain On

From the mongo.conf file, disable authorization under the security section.

security:
  authorization: disabled

Then restart mongodb using following command,

sudo systemctl restart mongod

Now, try to create your again. Do not forget to enable authorization back on after creating the user.