Friday, January 10, 2014

How to connect mongodb from console in Ubuntu

Access mongo from terminal:

Open Terminal with Ctrl + Alt + T then type below command:
mongo
List of all databases:
show dbs;
Select database for uses:
use db_development(db_name);
Display table list from db:
show tables;
Display data from table:
db.groups.find()
       where groups is a table name

Search content from table:

db.groups.find({name: "sachin"})
       where groups is a table name and name is field name

Set limit for display data from table:
db.groups.find().limit(2);
Reactions:

0 comments:

Post a Comment