Use of MongoDB command line-make your data storage more efficient

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.