Search code examples
mongodbmongodump

How to resolve error when trying to use mongodumb and -o/--out flag


I get the following error when I try to specify an output directory, how do I resolve this. According to the documentation, I think I'm doing everything right?

Command:

mongodump --db studioenterprise -o C:\Program Files\MongoDB\Dumps

Error:

2023-02-27T19:26:20.786-0600    error parsing command line options: error parsing positional arguments: provide only one MongoDB connection string. Connection strings must begin with mongodb:// or mongodb+srv:// schemes
2023-02-27T19:26:20.788-0600    try 'mongodump --help' for more information

I just downloaded and installed MongoDB tools.


Solution

  • According to https://www.mongodb.com/docs/database-tools/mongodump/#std-option-mongodump.--uri, the URI may be provided as a positional parameter.

    Furthemore, the --db and -o option values has to be passed with '=' as --db=studioenterprise and -o=C:\Program Files\MongoDB\Dumps otherwise, it will be considered as URI parameter.

    So the command looks like (assuming you have the mondogb instance running on localhost:27017):

    mongodump --db=studioenterprise -o="C:\Program Files\MongoDB\Dumps"