MongoDB Cheat Sheet. GitHub Gist: instantly share code, notes, and snippets. Name Summary; Connect to mongodb: mongo 192.168.75.108:12345/d2003 -u u2003 -p XXXX: Start mongo: mongod -config /etc/mongod.conf: Stop mongo: kill -15. Run this command. Connect to local host on default port 27017. Connect to remote host on specified port. Mongo — host — port. About this Cheat Sheet Basic Information The idea behind this is to have all (well, most) information from the above mentioned Tutorial immediately available in a very compact format. Mongo Shell Command History¶. You can retrieve previous commands issued in the mongo shell with the up and down arrow keys. Command history is stored in /.dbshell file. See.dbshell for more information. Command Line Options¶. The mongo shell can be started with numerous options. See mongo shell page for details on all available options. The following table displays some common options for.
MongoDB guide
By: Cian Clarke
Updated: 3/24/2017
By using the MongoDB shell, users can connect to local and remote databases. This cheat sheet can simplify your database operations through its listed commands for navigating Mongo, as well as queries for cursor operations.
This cheat sheet explains how to:
Start the MongoDB shell.
Navigate MongoDB with useful commands and queries.
Work with a collection, individual documents, and indexes.
Change groups of documents.
Avoid common dangers.
Access MongoDB shortcuts now
Navigate MongoDB
Mongodb Query Tutorial
Here are the most used commands, operations, and queries.
Help Methods and Commands | Description |
---|---|
show dbs | Shows all databases available on this server |
use acmegrocery | Switches to a database called acmegrocery. Creates this database if it doesn't already exist. |
show collection | Show all collections in the current db (first`use <someDb>`) |
show users | show all users for the current DB |
show roles | Show the roles defined for the current DB |