Basic MongoDB commands

Connect to Mongo database

mongo

Connect to Mongo on a different port (May be needed.  Port is for UniFi server)

mongo -port 27117

Show Databases

show dbs

Use database

use dbname

Show tables/collections

show collections

or

show tables

List users

show users

Authenticate

db.auth("username","password")

Insert into table

d = {"data":"data"}
db.collection.insert(d)

Example

d = {"name":"admin","lang":"en_US","x_password":"password","time_created":"","last_site_name":"default"}
db.admin.insert(d)

Leave a Reply