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)