Chapter 1: The Mongod Lab: Importing a Dataset Lab Failed: (Unauthorized)

Hi all,

i dont know why i cannot export the file.

  1. i opened the first terminal and type
    mongod --dbpath /var/mongodb/db --port 27000 --auth --logpath /var/mongodb/logs/mongod.log

  2. opened the second terminal and type
    mongo --port 27000
    and it connected to mongod

  3. i opened a new terminal andtype
    mongoexport --port 27000 -u “m103-application-user” -p “m103-application-pass” --authenticationDatabase “admin” --db dataset --collection products -o products.json

it says “2022-05-09T17:31:08.306+0000 Failed: (Unauthorized) not authorized on dataset to execute command { listCollections: 1, filter: { name: “products” }, lsid: { id: UUID(“57a4afd1-bb3c-4aff-83a0-08ec4d036450”) }, $db: “dataset” }”

Any step did i do it wrong?

I expected it will output a json file for me.

Thank you!

From the lab description:

The requirements for this command are:

  • import the data from /dataset/products.json
  • import the data to applicationData.products

You use mongoexport and the lab is about importing.

The --db parameter is wrong.

No, the lab is about importing the json file /dataset/products.js into the collection products of the database applicationData.

1 Like