MongoDB permissions, basic commands

Source: Internet
Author: User

MongoDB Common commands:

Talk about a special situation, if the admin uses encryption, then you create a database must be encrypted to use, this is the problem I personally met.

  Enter the MongoDB command line, note: The default entry is the test library $ mongo// admin  is the core group of database management, the total permissions console, stored the user name password role and other information.   Create a database, note: If the admin encryption, local login please first use username and password login admin in use//  Local login admin, first exit to System command line: $ mongo admin -- Username= User name  --password= password, then create the database using the following command > use youDatabase;//  switch the database, and create the same command, Note: If the admin is encrypted, you must encrypt the created database > use dbName//  encrypt the dbName, note: Version 3.0 with Db.createuser (' sa ', ' sa ') or Db.createuser ({User: ' sa ', pwd: ' sa ', roles:[', ']}); > db.adduser (' sa ', ' sa ');//  last another row of data authentication, the Safe Mode command only takes effect > db.auth (' sa ', ' sa ');//return 1 succeeded//  The encryption is deleted > db.removeuser (' sa ');//  to delete the database first use dbname to a > db.dropdatabase ();//  See what databases you have, first > use admin;//  then > show dbs;//  View all collections, using > show under the current database  collections;//  Insert > db.users.insert ({name: ' Test '});//  view all > db.users.find ();//   View a > db.user.findone ({_id:objectid (' 555DA6FBE19260407BE9EFBD ')});//  What's down there? UPDATE&NBSp;,remove Delete a document, much the same//  to delete a collection, under the current Database > db.users.drop ();//  View the current database name > db.getname ();//   View database version > db.version ();//  View the host address of the currently connected database > db.getmongo ();//  Show of course db status Condition >  Db.stats ();//  There's so much more.

MongoDB Remote Connection

$ mongo-u User name-p password IP address: 27017/dbname//Note: to the upper port good is the database default, you are what is what



MongoDB permissions, basic 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.