Set up common set db.createcollections AAA; Fixed set name book capped true fixed collection size Max: Number of documents Db.createcollection ("book", {capped:true, Size:10000,max:5}) "capped": false, indicates normal collection
Normal collections can be converted to fixed setsdb.user.convertToCapped (MaxBytes)-Calls {converttocapped: ' user ', size:MaxBytes}} Command
View the status of the collection db.aa.stats (); Delete Book collection db.book.drop (); Take out the file Mongofiles.exe get C:/myb.js
Auth Security Verification
Create Super Admin > Db.createuser ({User: ' admin ', pwd: ' 123 ', roles:[' root '}); Successfully added User: {"user": "admin", "Roles": ["root"]} Admin login verification via > use admin;switched to DB admin> Db.aut H (' admin ', ' 123 ');1>
Super Admin directly login server MONGO--host localhost--port 27017--username admin--password 123--authenticationdatabase Adminmongo--hos T 192.168.2.3--port 27017--username admin--password 123--authenticationdatabase Admin
Streamlined login I:\mongodb\bin>mongo localhost:27017/admin-u admin-p 123
Modify the Super Administrator password use admin;db.updateuser (' admin ', {pwd: ' admin '});
Create a database administrator, > Use hndb;switched to DB hndb> db.createuser ({User: ' AA ', pwd: ' AA ', roles:[' read '});
"ReadOnly": true; Indicates read-only "readOnly": false; Represents a super administrator created
Login HNDB Vault Administrator account password F:\mongodb\bin>mongo localhost:27017/hndb-u aa-p AA
Only the HNDB library can be used
MongoDB Loop Statement Output 0-20
var i=20;
print(i);
var i=0;
while(i<10){
print(i);
i++;
};
Query the database name all listed
var rs=db.student.find({},{_id:0,name:1,age:1});
while(rs.hasNext()){
print(rs.next().name);
}
Show name and age
Span class= "KWD" >var RS = db Span class= "pun". student find _id 0 name : 1 age : 1
while(rs.hasNext()){
var o=rs.next();
print("姓名"+o.name +",年龄"+o.age);
}
Put the f.rar of the C drive into the database F:\mongodb\bin>mongofiles.exe put C:/f.rar list all the information F:\mongodb\bin>mongofiles.exe list
Export File F:\mongodb\bin>mongofiles.exe get C:/f.rar
View upload list Information view fs.files content can log in later Db.fs.files.find ();
Import and export of data read only the name age field mongoexport/h localhost/port 27017/authenticationdatabase:admin/u admin/p admin/d hndb/c stude nt/o c:\j.js/f Name,age
Export all properties, all fields read out mongoexport/h localhost/port 27017/authenticationdatabase:admin/u admin/p admin/d hndb/c s/o c \ J.js Delete the table inside the database use hndb;> db.student.drop ();
Then the data is imported mongoimport/h localhost/port 27017/authenticationdatabase:admin/u admin/p admin/d hndb/c student C:\j.js
Remove condition Delete Partial content > db.student.remove ({age:{$gte: 70}});
Remove part of the content and then import, the original does not understand, no new content will be added and then log in and then view
From for notes (Wiz)
MongoDB fixed collection, establishing Administrator security authentication