Hi大家好,我是小魂。关于服务端命令,直接在cmd中敲help就能得到。但是每次都打help是不是太麻烦呢?好吧,我帮你把他弄出来了。如下:

db.help()   help on db methods
db.mycoll.help()   help on colleciton methods
rs.help()   help on replica set methods
help admin   administrative help
help connect   connecting to a db help
help keys   key shortcuts
help misc   misc things to know
help mr   mapreduce

show dbs   show database names
show collections   show collections in current database
show users   show users in current database
show profile   show most recent system.profile entries with time >= 1ms
show logs   show the accessible logger names
show log [name]   prints out the last segment of log in memory, 'global' is default
use <db_name>   set current database
db.foo.find()   list objects in collection foo
db.foo.find( { a : 1 } )   list objects in foo where a == 1
it   result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x   set default number of items to display on shell
exit   quit the mongo shell

DB methods: 
db.addUser(username, password[, readOnly=false]) 
db.auth(username, password) 
db.cloneDatabase(fromhost) 
db.commandHelp(name)      returns the help for the command 
db.copyDatabase(fromdb, todb, fromhost) 
db.createCollection(name, { size : ..., capped : ..., max : ...} ) 
db.currentOp()      display the current operation in the db 
db.dropDatabase() 
db.eval(func, args)      run code server-side 
db.getCollection(cname)      same as db['cname'] or db.cname 
db.getcollectionNames() 
db.getLastError()      - just returns the err msg string 
db.getLastErrorObj()      - return full status object 
db.getMongo()      get the server connection object 
db.getMongo().setSlaveOk()      allow this connection to read from the nonmaster member of a replica pair 
db.getName() 
db.getPrevError() 
db.getProfilingLevel()      - deprecated 
db.getProfilingStatus()      -returns if profiling is on and slow threshold 
db.getReplicationInfo() 
db.getSiblingDB(name)      get the db at the same server as this one 
db.KillOp(opid)      kills the current operation in the db 
db.listCommands()      lists all the db commands 
db.logout() 
db.printCollectionStats() 
db.printReplicationInfo() 
db.printSlaveReplicationInfo() 
db.printShardingStatus() 
db.removeUser(username) 
db.repairDatabase() 
db.resetError() 
db.runCommand(cmdObj)      run a database command. if cmdObj is a string, turns it into { cmdObj : 1 } 
db.serverStatus() 
db.setProfilingLevel(level,<slowms>) 0=off 1=slow 2=all 
db.shutdownServer() 
db.stats() 
db.version()      current version of the server 
db.getMongo().setSlaveOk()      allow queries on a replication slave server 
db.fsyncLock()      flush data to disk and lock server for backups 
db.fsyncUnlock()      unlocks server following a db.fsyncLock() 

posted on 2011-09-25 22:15  Tedycaml  阅读(199)  评论(0)    收藏  举报