2. MongoDB Common Commands

Source: Internet
Author: User

Tag:io    use    sp   on    data    div    bs   cti   ad   

Database common commands 1, help view command prompt   help  db.help ();  db.yourColl.help ();  db.youColl.find (). Help ();  Rs.help (); 2. switch/CREATE DATABASE  use yourdb;   when a collection (table) is created, the current database 3 is automatically created, all databases are queried  show dbs;4, and the currently used database is deleted  db.dropdatabase (); 5. Clone the database from the specified host  db.clonedatabase ("127.0.0.1"); Cloning data from the database on the specified machine to the current database 6, copying the specified database data from the specified machine to a database  db.copydatabase ("MyDB", "temp", "127.0.0.1"); Copy the MyDB data from the native to the temp database 7, fix the current database  db.repairdatabase (), 8, view the currently used database  db.getname (); db; The DB and GetName methods are the same effect, can query the currently used database 9, display the current DB status  db.stats (), 10, the current DB version  db.version (), 11, view the current DB link machine address   Db.getmongo ();  collection gather collection 1, create a clustered collection (table)  db.createcollection ("Collname", {size:20, capped:5, Max: 100}); 2, the Aggregation set (table)  db.getcollection ("account") that gets the specified name, 3, gets all the aggregation sets of the current DB  db.getcollectionnames (); 4, Displays the status of all clustered indexes in the current DB  db.printcollectionstats ();   user-related 1, adding a user  db.adduser ("name");  Db.adduser ("UserName", "pwd123", true); Add users, set passwords, read-only 2, database authentication, security mode  db.Auth ("UserName", "123123"); 3, display all current user  show users;4, delete user  db.removeuser ("userName");  other 1, error message before query  db.getpreverror (); 2, clear error logging  db.reseterror (); 

2. MongoDB Common Commands

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.