Lab: Importing a Dataset returning error

I’m getting some error while doing Lab: Importing a Dataset
First I connected to a mongod instance running on port 27000 with the credentials given by using
mongo --port 27000 --username m103-application-user --password m103-application-pass --authenticationDatabase admin
and it worked fine.

second, I tried to import the file by using the command
mongoimport --db applicationData --collection products --file /dataset/products.json

and got the following error:
2021-03-06T02:27:18.686+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14

What am I doing wrong here?

You may be running it from mongo prompt
Please exit and run the mongoimport from your os prompt with all needed params

If I exit, the port will be closed because I used
mongo --port 27000 --username m103-application-user --password m103-application-pass --authenticationDatabase admin

which takes me directly to the mongo prompt.
So should I open another terminal?

Nothing will happen if you exit
Please show screenshot of what you have tried
No need to open another terminal but if you wish you can open another terminal leaving the first one as it is
But make sure you are running mongoimport at operating sysytem prompt i,e $ or # if Unix
C:\Users\ if it is Windows

In recent versions of M103 you should be doing that inside the provided IDE.


I use the command below in the IDE and got the following error:
2021-03-08T21:03:38.039+0000 error validating settings: only one positional argument is

mongoimport --port 27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin -d applicationData –c applicationData.products --file /dataset/products.json

You will find the exact syntax and some examples at:

You seem to be missing some equal sign = between the argument name and its value. For example, it should be --port=27000 rather than --port 27000.


I followed the example on the link and tried this
mongoimport --port=27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin -d=applicationData –c=products '/dataset/products.json'

then I got this error:
error validating settings: only one positional argument is allowed

I tried the following
mongoimport --port=27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin -d=applicationData –c=products --file=/dataset/products.json
and I got the error below
error validating settings: incompatible options: --file and positional argument(s)

What am I doing wrong?

Try this
cd to the dir where your file is residing

mongoimport -u m103-application-user -p m103-application-pass --collection products --authenticationDatabase admin --db applicationData --port 27000 products.json

You can do different ways like with quotes,giving full path,with = and without=

1 Like

With the long option names, for example --username, and with an equal sign for all options and double quotes for username and password (as they may contain special characters) it works.

Even with -c, -d, -u and -p but with

it works.

So when do you use the = sign and when do you not use it?
I see that sometimes it’s being used and sometimes it’s not used.
@Ramachandra_Tummala suggested to try a command that doesn’t use the = sign.
So when do you use it and when can you omit it?

Did that worked?

I do not know the exact rules. But I play safe and always use them. I also use the long option names. It is easier to search my command history. And if it is a command I use often, I write a small script or an alias that wraps the real command.

1 Like

Well! When I don’t use the = sign, it doesn’t work.
It worked the = sign though.

1 Like

Hi @Alpha_Ly,

I hope that you had your issue get resolved.
Kindly feel free to reach out to us if you have any questions regarding the courses.