Daily Used Commands of Mongod

First we have to locate where the “mongo” command installed:

Now we start the mongod daemon on local machine and make sure it started successfully with the message “waiting for connections on ports 27017”.

 

After successfully start mongod daemon, we can use the “mongo” command line right now. just type “mongo” as following

To list all DBs on your machine, use command “show dbs”

In case you want to select another db, simply switch by command “use”:

Now we can list the collections and query any things as you want

To list all records in the collections “device”, do as following

The format of query as db.collection.find(queryprojection). For example 

 

To remove one record, do as following

For complete reference, check this link : https://docs.mongodb.com/v3.0/reference/method/js-collection/

 

Cheers.

Some useful mongo db command lines
Tagged on:
Share This

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Subscribe

To download the latest tutorials

You have successfully download

Enter Email To Download

Join our mailing list to receive the latest Application for free from IoTBreaks.

You have Successfully Subscribed!

flash Raspbian to SDCard

Enter Email To Download

Join our mailing list to receive the latest Application for free from IoTBreaks.

You have Successfully Subscribed!

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!