Chapter 1: Lab Creating First Application User

Getting a syntax error when entering everything in the command line. Here is my code:

db.createUser( {user: m103-application-user", pwd: "m103-application-pass", roles [ { db: "applicationData", role: "readWrite" } ] } )

Here is the error:

help

The command db.createUser() is a mongo shell command. You must be in the mongo shell to run it.

Hi @Max_Reinmueller,

Any update on this ?

~ Shubham

1 Like

That makes sense. Thank you for the feedback.

Hi @Shubham_Ranjan ,

I am still working on it but @steevej-1495 advice make total sense. I think the issue is that I dont’s understand how the --fork option is implemented.

when I run mongod -f mongod.conf I am triggering a exit code 48

Hi @Max_Reinmueller,

In a nutshell, the fork option enables daemon mode and the mongod process runs in the background.

You can read more about it here : processManagement - fork.

In this lab [Chapter 1: Lab: Creating First Application User], a mongod instance has already been started for you and hence you are not required to it.

Please re-read the instructions mentioned in the lab.

~ Shubham

1 Like

@Shubham_Ranjan and @steevej-1495 I did it! :smiley:

Thank you for your help. I was doing a few things incorrectly but you both put me on the right track.

Thank you!!

Hi i was trying to do the lab for creating first user where my mongod is runing behing and i am trying to runt the query in mongoshell, but still i face syntax error and i am not sure what mistake i am doing will you be able to help me out

Hi @nakeeran_Saravanan,

These are resources that helped me understand what was going on. I hope they will help you.

missing ;

missing }

1 Like

Your first attempt failed because you are at mongo prompt
mongo and mongod commands should be run from os prompt

Your second attempt db.createUser is correct but it gave message that user already exists

So just try to login with that user

1 Like

Hi @nakeeran_Saravanan,

Please let us know if you are still facing any issue.

~ Shubham

as Ramachandra_37567 mentioned i confirm that the user is already existing but still facing error while validating the work i have attached the screenshots for your reference please help to rectify the problem and validate. I also believe icould ogin to the db with credentials please look into that help ASAP.


It looks like you are terminating mongod just before running the script.

Hi @nakeeran_Saravanan,

This :point_down:

And also, are you running the mongod instance on the correct port ? It looks like that your mongod instance is running on the default port i.e. 27017.

~ Shubham

how do i know whether i am running instance in the correct port or not

Hi @nakeeran_Saravanan,

You can specify the port number at the time of starting the mongod instance.

If you do not specify the port then by default it will run on port 27017.

~ Shubham

i tried that too but still facing issue in connection

The validation script validate_lab_launch_mongod is telling you that you did not start mongod correctly. It tells you that you are missing the command line option or configuration file item needed to specify db path to the value /data/db.

The error about User “m103-admin@admin” already exists, means that you already create that user. Most likely you did that in a previous a lab. But since your db path is not /data/db may be the user does not exist at this data location.

Another thing I noted is that you have 2 tabs open on 2 different labs. It even looks like they are tabs from 2 different instances of the course. The give away is that the formatting of the title of labs are different. You cannot follow the instructions of 2 different instances of the course as the requirements are not exactly the same.

i understand that the user is already created that’s why i am trying to validate that where i am getting error. As specified i started mongod with port 27000 for which i have attached the screenshot they are not tabs of different instances, one is screenshot that i obtained as i run mongod command with port 27000 and another one is where i run the assessment command and validating command

Hi @nakeeran_Saravanan,

How are you starting your mongod instance ?

Just FYI - Since you are on the very first lab so I just wanted to let you know that recently we have launched a new version of the course which use IDE an In-browser Development Environment. This allows you to perform all the labs in your browser itself.

If you are interested then you can register for an IDE offering here : https://university.mongodb.com/courses/M103/about

~ Shubham