Chapter 4: Can't import companies.json


As topic name states I can’t import conpanies.json

I’ve taken a look at the following topics and solutions but there is no explicit solution:

I’ve managed to get a success response from the following command:

mongoimport --host \
--db companies \
--type json \
--file companies.json \
--collection companies \
--authenticationDatabase admin \
--ssl \
--username m121 \
--password aggregations

The success response is the following:

2020-01-27T15:20:41.094+0200	connected to: mongodb://
2020-01-27T15:20:44.099+0200	[###.....................] companies.companies	9.39MB/74.6MB (12.6%)
2020-01-27T15:20:44.140+0200	[###.....................] companies.companies	9.39MB/74.6MB (12.6%)
2020-01-27T15:20:44.140+0200	Failed: (Unauthorized) not authorized on companies to execute command { insert: "companies", ordered: false, writeConcern: { w: "majority" }, $clusterTime: { clusterTime: Timestamp(1580131240, 1), signature: { hash: BinData(0, D3DC8F1EA442AA1FB6597820E3E53D5D4E8CB1B4), keyId: 6730992026675838977 } }, $db: "companies" }
2020-01-27T15:20:44.140+0200	0 document(s) imported successfully. 0 document(s) failed to import.

But I still don’t see such db in my show dbs in my connected mongodb

I’m connecting to the cluster with the following command:

mongo "mongodb://,," \
--authenticationDatabase admin --ssl -u m121 -p aggregations --norc

What am I doing wrong?

It doesn’t look like a success to me.

Yeah, good point, just checked it 1 more time, indeed it is not a success.
Cloudy eye.

Could you please help me out, what is the correct way to import it?

This is the cluster for the class and it’s read only access for everyone. You can import it into your own Atlas cluster if you have one, or import it into your local standalone db (localhost).

1 Like

I see. Thank you for your help.
To be honest, this is astonishingly implicit and unintuitive.

Compass is also an option but there are some known bugs when trying to import large files.

Yeah, I’ve managed to connect to my own free cluster via compass and import it :slight_smile:

1 Like

It would be really awesome if we had this clearly detailed in the lecture, that collection has to be imported into your own cluster or local db

1 Like

:slightly_smiling_face: :+1:

I’m sure that the Curriculum Support Engineer for this course would take your feedback on board.

1 Like