Mongoimport Failed: (AtlasError) (Unauthorized) not authorized

first time trying to use mongoimport to add to a new collection in my free tier mongo cloud.
Failed: (AtlasError) (Unauthorized) not authorized on local to execute command { insert:

Hi @Joe_Shea,

Welcome to the community! :slight_smile:

Are you able to share the full mongoimport command you’ve run as well as the full error output? (Please redact any credentials before posting here)

Kind Regards,
Jason

1 Like

connected to: mongodb+srv://[REDACTED]@cluster0.vxy3a.mongodb.net/local
2021-07-04T18:59:58.935-0400 Failed: (AtlasError) (Unauthorized) not authorized on local to execute command { insert: “runid_202107_0418_5957-8dc41940-dd1b-11eb-9b7b-acde48001122”, ordered: false, writeConcern: { w: “majority” }, lsid: { id: {4 [89 128 67 95 128 77 75 168 168 164 31 0 219 156 3 29]} }, txnNumber: 1.000000, $clusterTime: { clusterTime: {1625439597 1}, signature: { hash: {0 [36 180 228 39 190 182 207 128 15 171 166 177 98 243 228 99 13 107 188 137]}, keyId: 6930011267755147264.000000 } }, $db: “local” }
2021-07-04T18:59:58.935-0400 0 document(s) imported successfully. 0 document(s) failed to import.

mongoimport --uri mongodb+srv:// [ REDACTED ]: [ REDACTED ]@cluster0.vxy3a.mongodb.net/local --collection runid_202107_0418_4005-c71076a6-dd18-11eb-9b7b-acde48001122 --file runid_202107_0418_4005-c71076a6-dd18-11eb-9b7b-acde48001122.json --jsonArray

Means you are not authorized to performed a command (insert in this case) on the local database. As far as I know the local database is read-only on Atlas cluster. It looks like the –collection parameter is ignored. I would try to replace local from your –uri with the collection name specified for the –collection parameter.

Thanks everyone. for your response and help!
Local mongo allows writing to local database. Atlas does not.