From charlesreid1

Revision as of 19:10, 17 August 2020 by Unknown user (talk) (Created page with "==Connecting== To figure out what's in a mongodb database, start by figuring out where mong is running and how to connect to it: <pre> ps aux | grep mongo </pre> This will...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Connecting

To figure out what's in a mongodb database, start by figuring out where mong is running and how to connect to it:

ps aux | grep mongo

This will show the currently-running mongo process and the command used to start it, which will tell you what port mongo is listening on. Suppose it's running on port 12121. Then we can connect to the mongo db this way:

mongo --port 12121
</pre

This will give us a shell prompt for the mongo db shell.

==Exploring==

Start by figuring out what databases there are. Run the listDatabases command this way:

<pre>
> db.adminCommand({listDatabases: 1})