Skip to content

Instantly share code, notes, and snippets.

@hochun836
Last active November 8, 2022 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hochun836/29124a9a84b5f8446f42aac207d5ae1f to your computer and use it in GitHub Desktop.
Save hochun836/29124a9a84b5f8446f42aac207d5ae1f to your computer and use it in GitHub Desktop.
# mongo shell
mongosh -h
mongosh --version
mongosh <db-address>
mongosh mongodb://<ip>
mongosh mongodb://<ip>:<port>
mongosh mongodb://<ip>:<port>/<db>
mongosh --host <ip>
mongosh --host <ip> --port <port>
mongosh --nodb // don't connect to mongod on startup - no 'db address' [arg] expected
inside mongo shell,
> help
> version()
> print("Hello World")
> isInteractive()
> cls
> exit // <=> exit() <=> .exit
> show profile // print system.profile information
> show dbs // <=> show databases
> use <db>
> show collections // <=> show tables, for current database
> show users // for current database
> show roles // for current database
NOTE: installation
=> ref: https://www.mongodb.com/docs/mongodb-shell/install/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment