mongo
legacy MongoDB shell
TLDR
Connect to local database
$ mongo
Connect to remote database$ mongo [mongodb://host:27017/dbname]
Connect with authentication$ mongo -u [user] -p [password] [dbname]
Execute JavaScript file$ mongo [dbname] [script.js]
Evaluate expression$ mongo --eval "[db.collection.find()]"
Connect with SSL$ mongo --ssl --host [host]
SYNOPSIS
mongo [options] [dbaddress] [filenames]
DESCRIPTION
mongo is the legacy MongoDB shell. It provides interactive JavaScript interface to MongoDB.
The tool connects to mongod instances. Supports queries, administration, and scripting.
PARAMETERS
DBADDRESS_
Database connection string.-u USER
Username for authentication.-p PASSWORD
Password for authentication.--eval EXPR
Evaluate JavaScript expression.--ssl
Use SSL connection.--host HOST
Server hostname.--help
Display help information.
CAVEATS
Deprecated in favor of mongosh. MongoDB 4.4 and earlier. JavaScript-based.
HISTORY
mongo was the original MongoDB shell, now replaced by mongosh for MongoDB 5.0+.
SEE ALSO
mongosh(1), mongod(1), mongoimport(1)
