Error parsing command line options: error parsing positional arguments:

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

How to fix this error
i tried to import a json file using
mongoimport json_path.json -d database_name -c collection_name

If you look at the mongoimport documentation you will see that you are using the wrong syntax. It looks like you are missing = after -d and -c.

Hi @Harison_Lopez and @steevej! You can actually use either an = or a space between an option and its argument. Although the docs use = to be consistent, both are valid.

@Harison_Lopez this error occurs when the command sees two positional arguments (i.e. two strings not prefixed by an option like -c). Does the path to your file or your collection name include a space? A space in your file path or in another option argument will cause the part after the space to be parsed as an extra positional argument. In bash, you can fix this by putting quotes around your strings like this:

mongoimport "json_path.json" -d "database_name" -c "collection_name"

Or by escaping spaces in your path with a backslash \: e.g. /path\ with\ spaces/file.json