MongoDB Shell (mongo)

The mongo shell is an interactive JavaScript interface to MongoDB and is a component of the MongoDB package. You can use the mongo shell to query and update data as well as perform administrative operations.

Start mongo

Once you have installed and have started MongoDB, connect the mongo shell to your running MongoDB instance. Ensure that MongoDB is running before attempting to launch the mongo shell.

On the same system where the MongoDB is running, open a terminal window (or a command prompt for Windows) and run the mongo shell with the following command:


On Windows systems, add .exe as follows:


You may need to specify the path as appropriate.

When you run mongo without any arguments, the mongo shell will attempt to connect to the MongoDB instance running on the localhost interface on port 27017. To specify a different host or port number, as well as other options, see mongo Shell Reference Page.

Help in mongo Shell

Type help in the mongo shell for a list of available commands and their descriptions:


The mongo shell also provides <tab> key completion as well as keyboard shortcuts similar to those found in the bash shell or in Emacs. For example, you can use the <up-arrow> and the <down-arrow> to retrieve operations from its history.

Additional Information

See the following documents in the MongoDB Manual for more information on the mongo shell.