MongoDB Learning Notes (ii)

Source: Internet
Author: User

MONGO Command and Configuration
1. Startup items

1 --DBPath directory of the specified database 2 --Port ports default is 270173 --fork to boot in the background daemon way 4 --logpath developing log file output path 5 --config Specify a profile 6 --auth start the database in a secure manner  7 --rest will start a help page

2. Close the database

Db.shutdownserver ();

3. Import and Export

-Export Mongoexport
-D Specify the exported database
-C set up the exported collection
-O Exported file path
-Q for filtering

mongoexport-d local-c Person-o Bak.json

  

-Import Mongoimport

mongoimport-d local--collections person--file Bak.json

-Import the entire library

Mongorestore--directoryperdb Bak.dmp

4. Lock Write

Db.runcommand ({fstnc:1,lock:1});

5. Unlocking

Db.fsyncunlock (); Lock and write when backing up, and unlock after backup to ensure data integrity

6. Adding roles

Db.adduser ({' Chuhan ': ' 123 '}); Deprecated does not recommend using Db.createuser ({User: ' Chuhan ', pwd: ' 123 ', Roles:[{role: ' Useradmin ', db: ' Admin '}]})

7. Show all the characters

Db.showroles

  

8. Modify User Password

Db.changeuserpassword (' Chuhan ', ' 123 ');

9. Authorized Login

Db.auth (' Chuhan ', ' 123 '); If 1 is displayed, it is successful, otherwise the authorization fails

10. View User Permissions

Db.runcommand ({usersinfo: ' Chuhan ', showprivileges:true});

11. Modify User Permissions

Db.runcommand ({updateUser: ' Chuhan ', pwd: ' 789 ', Customdata:{title: ' manager ', Age:12}})

  

MongoDB Learning Notes (ii)

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.