LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mongosh

modern MongoDB shell

TLDR

Connect to local database
$ mongosh
copy
Connect to specific database
$ mongosh [mongodb://host:27017/dbname]
copy
Connect with authentication
$ mongosh -u [user] -p [password] [dbname]
copy
Execute script file
$ mongosh [dbname] [script.js]
copy
Evaluate expression
$ mongosh --eval "[db.collection.find()]"
copy
Start shell without connecting to a database
$ mongosh --nodb
copy
Connect with TLS to a remote host
$ mongosh --tls "mongodb://[host]:27017/[dbname]"
copy
Quiet mode (suppress startup messages)
$ mongosh --quiet [script.js]
copy

SYNOPSIS

mongosh [options] [connectionstring] [filenames]

DESCRIPTION

mongosh is the modern MongoDB shell, providing a fully functional JavaScript and Node.js REPL environment for interacting with MongoDB deployments.It replaces the legacy mongo shell with improvements including syntax highlighting, intelligent autocomplete, inline help, and extensible snippets. It supports all CRUD operations, aggregation pipelines, database administration, and Atlas connectivity.

PARAMETERS

CONNECTIONSTRING_

MongoDB connection URI.
-u USER
Username for authentication.
-p PASSWORD
Password for authentication.
--eval EXPR
Evaluate JavaScript expression.
--nodb
Start without database connection.
--quiet
Silence non-essential output.
--host HOST
Server hostname (default: localhost).
--port PORT
Server port (default: 27017).
--authenticationDatabase DB
Authentication database (default: admin).
--tls
Enable TLS/SSL connection.
--shell
Force interactive shell after running files/eval.
--help
Display help information.

INSTALL

brew install mongosh
copy
nix profile install nixpkgs#mongosh
copy

CAVEATS

Bundles its own Node.js runtime since version 1.0. Compatible with MongoDB 4.0+, though some features require MongoDB 5.0+. Has a different driver API from the legacy mongo shell; scripts may need updating.

HISTORY

mongosh was released by MongoDB in 2020 as the next-generation shell replacement for the legacy mongo shell.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid