Mongdodb instance-"Database-" collection-"Document-" field (Key/value pair)
Bin execution./mongod Startup & Background Boot
./mongo into MongoDB shell Many of these commands resemble MySQL show DBS (view database)
Start Error:/data/db/mongod.lock is not empty.
Kill Mongod, delete mongod.lock, this file resembles record MongoDB still start cache file
Create a database
Use namedb Create a database named Namedb and insert the data before you can view it via show DBS
Deleting a database
Use Namedb first enters the database Db.dropdatabase () and then deletes the database (the test database is deleted by default if you do not enter the appropriate database)
Create a collection in the database
Db.createcollection ("CollectionName")
To delete a specified collection in a database
Db.collectionName.drop ()
Inserting a document into the collection
Db.collectionName.insert ({"Namedockey": "Namedocvalue"}) similar to the Save method
Querying collection data
Db.collectionName.find () query. Pretty () query and format display Db.collectionName.find ({"Key": "Value"}); Querying the specified document
Modifying a document
Db.collectionName.update ({"Key": "Value"},{"NewKey": "Value"},{upsert:true}) Upsert=true if not present, Insert Db.collectionName.update ({"Key": "Value"},{$set: {"Oldkey": "NewValue"}}) to modify the specified property
Delete a document
Db.collectionName.remove ({}) deletes all documents in the collection without deleting the collection db.collectionName.list.remove ({"Key": "Value"}) deletes the specified document
This article is from the "Stuffed Pig" blog, please be sure to keep this source http://zuohao1990.blog.51cto.com/6057850/1883265
MongoDB Basic Operations