About MongoDB
MongoDB is a non-relational database (NOSQL) that is currently very popular in the IT industry, and its flexible data storage methods are favored by current it practitioners. Features: High performance, easy to deploy, easy to use, easy to store data. This article describes the use of MongoDB's command line to make MONGODB operations more efficient.
MongoDB Features: High performance, easy to deploy, easy to use, storage data is very convenient.
Functional Features:
- Collection-oriented storage for easy storage of object-type data
- Mode freedom
- Support Dynamic Query
- Full index support, including internal objects
- Support Query
- Support for replication and failure recovery
- Use efficient binary data storage, including large objects (such as video, etc.)
- Automatically process fragmentation to support scalability at the cloud level
- Supports multiple languages such as node.js,ruby,python,java,c++,php
- File storage format is Bson (an extension of JSON)
- Accessible over the network
It is visible that MongoDB is very powerful. Therefore, mastering the use of the MongoDB command line can make your data storage more efficient.
Start MongoDB
[Email protected] ~]# CD usr/local/mongodb/bin[[email protected] bin]#. /2.6. 6 Connecting To:test
At this point, MongoDB started successfully!
MongoDB basic Commands
Show Database list
Show DBS
Display a collection in the current database (similar to a table in a relational database)
Show collections
Show Users
Show Users
Database Common Commands
Switch/CREATE Database
Use Yourdb
Querying all databases
Show DBS
Delete the currently used database
Db.dropdatabase ()
View the database currently in use
Dbdb.getname
View the link machine address of the current DB
Db.getmongo ()
Create a Clustered collection (table)
- 5 +})
Get all the clustered collections of the current DB
Db.getcollectionnames ()
Gets the Clustered collection (table) of the specified name
Db.getcollection ("collectionname")
Clustered collection Query
Querying All records
Db.collectionname. Find ()
Query the first 5 data
Db.collectionname. Find (). Limit (5)
Query for data after 10
Db.collectionname. Find (). Skip (ten)
Querying for data between 5-10
Db.collectionname. Find (). Limit (ten). Skip (5)
Querying the first piece of data
Db.collectionName.findOne ()
Modifying a document
db.collectionName.update ({columnName: Columnval }, {$set: {columnName: columnval ", ColumnName: " columnval " }} false , true )
Delete a document
" Columnval "})
User-related
Add a user
Db.adduser ( name " ) Db.adduser ( " username , " pwd123 , true ) add user, set password, read-only
Show all current users
Show Users
Delete User
Db.removeuser ("username");
Use of MongoDB command line-make your data storage more efficient