M103 - Error: No Users Authenticated

Hello Everyone!

I’m trying to create the “m103-admin” user for Lab 1 and I am running into the “There are no users authenticated” error when I try to create said user.

I’ve looked at other threads and used functions like db.getUser() to see if the user has already be created but the db.getUser() method returns a 0. Additionally, I’m not able to replicate the solutions that other students have followed.

My thought process is to completed this lab is as follows:

  1. Set up the daemon using: “mongod --port 27000 --dbpath /data/db/ --bind_ip “,” --auth”
  2. Opening another tab in my terminal and using the mongo shell to connect to the port: “mongo --port 27000”
  3. Switching to the admin database: “use admin”
  4. Finally, typing in the create user command: “db.createUser({user: “m103-admin”, pwd: “m103-pass”, roles: [{role: “root”, db: “admin”}]})”

At this point I run into the error below:
2019-11-18T16:36:09.567+0000 E QUERY [thread1] Error: couldn’t add user: there are no users authenticated :

Also, I do want to mention that when I try to use the command “show dbs” after switching over to the admin database I get this error:
2019-11-18T16:56:56.363+0000 E QUERY [thread1] Error: listDatabases failed:{
“ok” : 0,
“errmsg” : “there are no users authenticated”,
“code” : 13,
“codeName” : “Unauthorized”
} :
This might indicate that I’m not properly authorized to use the admin database even if I switch to it since I cannot show the databases on this port.

Am I missing a crucial step or overlooking something simple? Thank you to those who take their time out to read this. Any and all help is appreciated!

You have already created the user. You just need to authenticate by using:

Thank you for the quick response!

Should I be using this command in the mongo shell or before I connect to the port? I’m getting an “Authentication Failed” issue.

vagrant@m103:~$ mongo --port 27000
MongoDB shell version v3.6.15
connecting to: mongodb://
Implicit session: session { “id” : UUID(“7fd42352-00c0-4641-a47c-4f22c6506890”) }
MongoDB server version: 3.6.15
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.auth(“m103-admin”, “m103-pass”)
Error: Authentication failed.

You’re in the right place. There’s a possibility that you created the user in a different db.

Do you remember how many times you ran the createUser() command? Try and use the default test db to authenticate. If it works, let me know and I’ll give you the steps to start from scratch to get it to work.

You’re right. I mistakenly created the user in the default mongod connection.

I used db.auth() and it returned:
MongoDB Enterprise > db.auth(“m103-admin”, “m103-pass”)

If this is what you were talking about, may you please show me those steps you mentioned to start from scratch?

Yeah, that’s the one. You’ve already used up the localhost exception so you’ll need to start from scratch using these steps:

  1. Shutdown the server:
    use admin
  2. If step 1 doesn’t work, find the process id by running ps -ef | grep "[m]ongod" in the linux shell (not mongo shell) and kill it using kill -9 <process id>
  3. Delete all the db files:
    rm -r /path/to/db/*
    rm /path/to/log/log_name.log

Now you can restart the mongod and login to mongo

I was able to kill the process in step 2. However, in step 3 should I run the commands in the Linux shell too or should I start Vagrant and run those commands instead.

Linux shell as well. You can get the full paths from your config file.

I have ran the commands in step 3 under my m103-vagrant-env directory in the Linux shell but the shell comes back with:
rm: cannot remove ‘/path/to/db/*’: No such file or directory
rm: cannot remove ‘/path/to/log/log_name.log’: No such file or directory
Would these paths be somewhere else instead of the m103-vagrant-env directory?

I ask because I tried locating my config file but was unable to find it. Other threads mentioned that it should be under the shared folder. I have this folder but nothing is in it.

Even though I could not find the paths that you specified in step 3, should I proceed towards restarting mongod and logging back into mongo?

Edit: I was specifically looking for a file called “config.” My mistake

You didn’t use a config file so the path is here. So just run:
rm -r /data/db/*

There’s a lecture about using config files but you haven’t gotten to that lecture yet.

Ah, okay.

I still received a similar response after running the remove command:
rm: cannot remove ‘/data/db/*’: No such file or directory

Would this file path be located anywhere else instead of the m103-vagrant-env directory?

Try these two steps:
rm -r /data/db
mkdir /data/db

Got it. I created the data/db file path

What would be my next step?

Go ahead with what you did from your original post and you should be fine

I got it!

  1. Here’s the authentication:
    MongoDB Enterprise > db.auth(“m103-admin”, “m103-pass”)

  2. And here’s the creation:
    MongoDB Enterprise > use admin
    switched to db admin
    MongoDB Enterprise > db.createUser({user: “m103-admin”, pwd: “m103-pass”, roles: [{role: “root”, db: “admin”}]})
    2019-11-18T19:24:13.039+0000 E QUERY [thread1] SyntaxError: illegal character @(shell):1:21
    MongoDB Enterprise > db.createUser({user: “m103-admin”, pwd: “m103-pass”, roles: [{role: “root”, db: “admin”}]})
    Successfully added user: {
    “user” : “m103-admin”,
    “roles” : [
    “role” : “root”,
    “db” : “admin”

I was able to run validate_lab_launch_mongod and get the hash ID to successfully complete the lab.

Thank you so much for your time and patience. I’ve seen you helping others in other threads and I just wanted to say even if this worked or not that you’re doing a wonderful job. Thank you again!

Glad you got it working!


Hi @007_jb, Thanks for you contribution.

Hi @Dylan_86023,

I’m glad your issue got resolved. If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Shubham Ranjan
Curriculum Support Engineer