1 #进入数据库
use admin
2 #增加或修改密码
db.addUser(‘xingoo’,’123′)
db.addUser(“xingoo”,”123″,true) 参数分别为 用户名、密码、是否只读
3 #查看用户列表
db.system.users.find()
4 #用户认证
db.auth(‘xingoo’,’123′)
5 #删除用户
db.removeUser(‘xingoo’)
6 #查看所有用户
show users
7 #查看所有数据库
show dbs
8 #查看所有的collection集合
show collections
9 #查看各个collection的状态
db.printCollectionStats()
10 #查看主从复制状态
db.printReplicationInfo()
11 #修复数据库
db.repairDatabase()
12 #设置profiling,0:off 1:slow 2 all
db.setProfilingLevel(1)
13 #查看profiling
show profiling
14 #拷贝数据库
db.copyDatabase(‘xingootest’,’xingootest1′)
db.copyDatabase(“xingootest”,”temp”,”127.0.0.1″)
15 #删除集合collection
db.xingootest.drop()
16 #删除当前数据库
db.dropDatabase()