# Mongoimport not working

**URL:** <https://forum.codewithmosh.com/t/mongoimport-not-working/2341>\
**Category:** Node\
**Created:** [January 30, 2021, 12:32am UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341 "2021-01-30T00:32:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 30, 2021, 12:32am UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/1 "2021-01-30T00:32:41Z")

</div>

I’m CRUD operations episode-14, and I’m trying to import files to my mongodb compass (mongoimport --db mongo-exercises --collection courses – file exercise-data.json --jsonArray).

The first error I got is “mongoimport is not recognized as an internal or external command”.  
That’s when I realized that I didn’t have that import module installed in my bin folder. Afterwards I downloaded the zip file for it:

> **[Download MongoDB Command Line Database Tools](https://www.mongodb.com/try/download/database-tools)**
>
> Command line tools available for working with MongoDB deployments. Tools include mongodump, mongorestore, mongoimport, and more. Download now.

Then I followed this tutorial on how to install it:

> **[Installing the Database Tools on Windows — MongoDB Database Tools 100.2.1](https://docs.mongodb.com/database-tools/installation/installation-windows/)**

Ater installing the modules neccessary, I get another error in the terminal

“2021-01-29T17:21:35.122-0700 error parsing command line options: error parsing positional arguments: provide only one file name and only one MongoDB connection string. Connection strings must begin with mongodb:// or mongodb+srv:// schemes  
2021-01-29T17:21:35.128-0700 try ‘mongoimport --help’ for more information”.

Here’s my bin:

![mongo_bin](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/bac6fdf6a2f2f376bea2cd3378470ea73ff2573f.png)

PLEASE HELP!

---

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 30, 2021, 1:57am UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/2 "2021-01-30T01:57:55Z")

</div>

I solved it; the last error was a syntax error as there was a space between the dashes and file. (-- file) should be (–file).

Also if anyone else is experiencing that import error: “mongoimport is not recognized as an internal or external command”, check the the 2 links I posted above.

---

<div class="post-metadata">

**Author:** ![dev-ous](https://avatars.discourse-cdn.com/v4/letter/d/4bbf92/32.png) [@dev-ous](https://forum.codewithmosh.com/u/dev-ous)\
**Post date:** [June 6, 2022, 10:52pm UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/3 "2022-06-06T22:52:40Z")

</div>

Thank you so much you saved me !

---

<div class="post-metadata">

**Author:** ![djb160](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/djb160/32/4881_2.png) [@djb160](https://forum.codewithmosh.com/u/djb160)\
**Post date:** [February 17, 2023, 4:39am UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/4 "2023-02-17T04:39:03Z")

</div>

Steps for windows if you hit this issue:

1. [Download MongoDB Command Line Database Tools | MongoDB](https://www.mongodb.com/try/download/database-tools)
2. Extract
3. I copied the folder into C:\Program Files\MongoDB\ for convenience
4. Edit your Environment Variables \> System \> PATH \> New \> (C:\Program Files\MongoDB\mongodb-database-tools-windows-x86\_64-100.6.1\bin). Save.
5. Close and re-open VSCode to be able to pick up the new Path item.

Should be able run the mongoimport command now

---

<div class="post-metadata">

**Author:** ![Andrew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/andrew/32/5483_2.png) [@Andrew](https://forum.codewithmosh.com/u/Andrew)\
**Post date:** [April 24, 2023, 11:07pm UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/5 "2023-04-24T23:07:58Z")

</div>

For anyone else on 14 Exercise 1, I was successful in executing this long command:

mongoimport --db mongo-exercises --collection courses --drop --file exercise-data.json --jsonArray

The trick is to make sure you navigate into the exercise folder. That’s because the json file (exercise-data.json) lives in there, not in the root.

---

<div class="post-metadata">

**Author:** ![Kingslee](https://avatars.discourse-cdn.com/v4/letter/k/ad7895/32.png) [@Kingslee](https://forum.codewithmosh.com/u/Kingslee)\
**Post date:** [June 29, 2023, 10:39am UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/6 "2023-06-29T10:39:39Z")

</div>

I don’t see a solution for Mac users

---

<div class="post-metadata">

**Author:** ![Bravono](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/bravono/32/3426_2.png) [@Bravono](https://forum.codewithmosh.com/u/Bravono)\
**Post date:** [December 4, 2023, 1:16pm UTC](https://forum.codewithmosh.com/t/mongoimport-not-working/2341/7 "2023-12-04T13:16:52Z")

</div>

You saved my life as well
