I've installed mongodb the next way on Ubuntu 20.04:

wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt update
sudo apt install mongodb-org

Then I've downloaded sample mongodb database:

wget https://atlas-education.s3.amazonaws.com/sampledata.archive

But I do not know how to import it on Ubuntu. I've imported it on Windows using Studio 3T application. Also, it could be done by using this application from windows if I configure authentication on my remote ubuntu server, open in firewall required port and enable binding for mongodb on in /etc/mongod.conf.

But on Ubuntu, when I rename it to sampledata.archive.bson and try to import it, I get the next output with the error:

user@server:~/projects/mongodb_sample_db$ mongorestore sampledata.archive.bson
2023-03-02T15:21:00.155+0100    checking for collection data in sampledata.archive.bson
2023-03-02T15:21:00.155+0100    restoring to existing collection test.sampledata.archive without dropping
2023-03-02T15:21:00.155+0100    restoring test.sampledata.archive from sampledata.archive.bson
2023-03-02T15:21:00.201+0100    finished restoring test.sampledata.archive (0 documents, 0 failures)
2023-03-02T15:21:00.201+0100    Failed: test.sampledata.archive: error restoring from sampledata.archive.bson: reading bson input: invalid BSONSize: -2120621459 bytes is less than 5 bytes
2023-03-02T15:21:00.201+0100    0 document(s) restored successfully. 0 document(s) failed to restore.

The possible cause of the error: the file size is too big:

4983289 -rw-rw-r--  1 user user 305M Mar 10  2022 sampledata.archive.bson

How can I import it?

1 Answer 1


Have a look at The MongoDB Atlas Sample Datasets

For me it works:

mongorestore.exe --uri="mongodb://admin:*****@localhost:27017/?authSource=admin" --archive=sampledata.archive

2023-03-03T10:50:50.768+0100    preparing collections to restore from
2023-03-03T10:51:03.840+0100    424065 document(s) restored successfully. 0 document(s) failed to restore.
  • It seems it works, thank you. It is better do not put password between mongodb://admin: and @localhost:... because it will be visible in history and you need to remove it from there.
    – Gryu
    Commented Mar 3, 2023 at 19:20
  • The password would be also visible in ps, see jira.mongodb.org/browse/TOOLS-2768 If you are concerned about security I suggest option --config Commented Mar 3, 2023 at 21:20
  • Process of importing through mongorestore in ps looks like:
    – Gryu
    Commented Mar 3, 2023 at 21:33
  • user 3902941 6.1 0.8 1385196 68652 pts/0 Sl+ 22:32 0:00 mongorestore --uri=mongodb://mongouser@localhost:27017/?authSource=admin --archive=/home/user/projects/mongodb_sample_db/sampledata.archive.bson
    – Gryu
    Commented Mar 3, 2023 at 21:34
  • So no password visible if I do not specify it in uri
    – Gryu
    Commented Mar 3, 2023 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.