Skip to content

Useful MongoDB commands

roscisz edited this page Jul 26, 2017 · 1 revision

In all of the below commands it is assumed that database is at localhost. To connect to database at other server add to the parameters: --host :. You may also specify other filename for the file on local filesystem than filename used in mongo by specifying --local <local_filename>.

Listing available files

To list available files for use as input run:

mongofiles --db hive-dataserver -u hive-dataserver -p hive-dataserver --authenticationDatabase admin list

Adding file

To add file run:

mongofiles --db hive-dataserver -u hive-dataserver -p hive-dataserver --authenticationDatabase admin put 

Retrieving file

To retrieve file from database run:

mongofiles --db hive-dataserver -u hive-dataserver -p hive-dataserver --authenticationDatabase admin get 

Deleting file

To delete file from database run:

mongofiles --db hive-dataserver -u hive-dataserver -p hive-dataserver --authenticationDatabase admin delete 

It is especially useful for removing output files as each consecutive run creates output file with the same name.