Lab: Creating First Application user

I have been trying to solve this for several hours now, the guides here are ridiculous since there is literally nothing to work off of. I start the mongod with the following conf file:
storage:
dbPath: /var/mongodb/db
net:
bindIp: 0.0.0.0
port: 27000
security:
authorization: disabled

Setting auth to enabled makes me unable to start it.
with it running, I then try to connect using the following:
mongo admin -u m103-admin -p m103-pass

No matter what, I am always unable to connect, constantly giving me the following message:
MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27017/admin?gssapiServiceName=mongodb
2020-12-18T17:17:11.774+0000 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

I have no clue what I did wrong, and there are no materials to work off of since the videos barely explain things.

EDIT: I am able to connect to the port 27000 by using mongo --port 27000 but now I am unable to create a user.

Post a screenshot of what you are trying that shows the error you are getting.

Nobody can help with just:

My bad. Here is my full flow
use admin
switched to db admin

db.createUser(
… { user: “m103-application-user”,
… pwd: “m103-application-pass”,
… roles: [ { db: “applicationData”, role: “readWrite” } ]
… }
… )
2020-12-18T18:14:57.797+0000 E QUERY [js] Error: couldn’t add user: command createUser requires authentication :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1491:15
@(shell):1:1

You are missing a critical step.

Only the first user can be created without authentication. The lab states

The m103-admin user has also already been created for you with password m103-pass.

That’s what the error message

is telling you.

1 Like