M103 - As part of 'mongoimport' database or collection not listing after mongo shell connected

As part of course Id M103, chapter#1, i am trying to do Lab for “mongoImport”. As per guidance step It says mongod already running . connect with it and import the collection ‘products’ from database ‘applocationData’.
But when i run below command to connect mongo shell and run show dbs, nothing listing. Could you please help?

mongo --host localhost:27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin

Did you complete the import?
If yes you should be able to see the db

When I try to do import, its giving error. Because no database or collection I could see after I connect to mongo shell. even I tried “use applicationData”. But nothing works

Please see the things i ran in terminal

user@M103# mongo --host localhost:27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin


.

mongoimport --host localhost:27000 -u “m103-application-user” -p “m103-application-pass” --authenticationDatabase “admin” products.json
2022-10-19T15:34:46.541+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14
show dbs
use applicationData
switched to db applicationData
show collections

Don’t use localhost:port
Just use --port 27000
What is your target DB?
You have to pass that param to tell mongoimport about your target DB

target db is “applicationData”. Target collection “products”
I used --port 27000. Also added target db and collection as well in import. Still same issue

user@M103# mongo --port 27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin
MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27000/?authSource=admin&gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“80ebc829-fd3d-450f-9643-22356ca0fff6”) }
MongoDB server version: 4.0.5
Welcome to the MongoDB shell.
For interactive help, type “help”.
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user

mongoimport --host localhost:27000 -u “m103-application-user” -p “m103-application-pass” --authenticationDatabase “admin” --db applicationData --collection products products.json
2022-10-19T16:09:01.421+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14
mongoimport --port 27000 -u “m103-application-user” -p “m103-application-pass” --authenticationDatabase “admin” --db applicationData --collection products products.json
2022-10-19T16:09:37.533+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14

mongoimport --port 27000 -u “m103-application-user” -p “m103-application-pass” --authenticationDatabase “admin” --db applicationData --collection products --file products.json
2022-10-19T16:10:12.476+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14
mongoimport --port 27000 -u “m103-application-user” -p “m103-application-pass” --authenticationDatabase admin --db applicationData --collection products --file products.json
2022-10-19T16:10:44.380+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14
mongoimport --port 27000 -u m103-application-user -p m103-application-pass --authenticationDatabase admin --db applicationData --collection products --file products.json
2022-10-19T16:11:29.960+0000 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:14

Looks like you are running mongoimport while connected to mogodb
Please exit and run it from os prompt

2 Likes

Thank you. It worked.
I was trying to connect mongo shell and trying to run import.