Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got "too many positional arguments" error on mongorestore

Tags:

mongodb

I am trying to restore a existing mongodb database data..when i restore that by command line i got this line as error

2017-06-10T12:27:55.474+0530 too many positional arguments 2017-06-10T12:27:55.476+0530 try 'mongorestore --help' for more information

I used this line C:\Program Files\MongoDB\Server\3.4\bin> mongorestore F:\mongo_db\db

Anyone please help me to get rid from this error

like image 365
Janen R Avatar asked Oct 30 '22 06:10

Janen R


2 Answers

I found the solution after some time. Alternatively, we don't want to point the mongodb folder as of my question C:\Program Files\MongoDB\Server\3.4\bin> . Simply Used this command . It restores the existing database, else creates the database if it's not existing.here,

mongorestore --host <database-host> -d <database-name> --port <database-port> foldername

Don't forgot to start mongodb server before use this command. For your localhost

database-host --> localhost database-name --> Your db Name database-port --> 27017

like image 94
Janen R Avatar answered Nov 15 '22 09:11

Janen R


This error may occur when your folder name have space or hyphen(-) nomenclature, Please check the database contain folder name that it should not have any space or hyphen(-) in its nomenclature before restoring the database.

Below are used and tested cmd command line query for mongodb database restore

C:\Program Files\MongoDB\Server\4.0\bin>mongorestore -d foldername folderpath

Foldername - Name of the folder where your database dump exist.

Folderpath - A complete path(url) of your system where it database dump exist.

like image 36
shruti Avatar answered Nov 15 '22 08:11

shruti