Chapter 1: The mongod, mongoimport, not authorized

I am having the below error while trying to import the products.json files, and i doubled checked my users as below

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > show users
{
“_id” : “admin.m103-admin”,
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
}
{
“_id” : “admin.m103-application”,
“user” : “m103-application”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
}
{
“_id” : “admin.m103-application-user”,
“user” : “m103-application-user”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
}
vagrant@m103:~$ mongoimport --port 27000 --username m103-application --password m103-application-pass --authenticationDatabase “admin” --db applicaionData --collection products /dataset/products.json
2019-03-03T19:40:52.749+0000 connected to: localhost:27000
2019-03-03T19:40:52.808+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:52.856+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:52.904+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:52.947+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:52.992+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:53.029+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:53.061+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:53.092+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:53.124+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }
2019-03-03T19:40:53.160+0000 error inserting documents: not authorized on applicaionData to execute command { insert: “products”, writeConcern: { getLastError: 1, w: 1 }, ordered: false, $db: “applicaionData” }

May be it is because you do not mongoimport to the right database:

1 Like