Mongo/Spelunking: Difference between revisions
From charlesreid1
(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...") |
|||
| Line 11: | Line 11: | ||
<pre> | <pre> | ||
mongo --port 12121 | mongo --port 12121 | ||
</pre | </pre> | ||
This will give us a shell prompt for the mongo db shell. | This will give us a shell prompt for the mongo db shell. | ||
Revision as of 19:10, 17 August 2020
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
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:
> db.adminCommand({listDatabases: 1})