MongoDB Open authentication and user management
./MONGO # Login to use admin # to switch to Admin library Db.adduser ("Root","123456") # Create user Db.adduser ('Zhansan','Pass',true)
# If the user's readonly is true then the user can only read the data and add a readonly user Zhansan
./mongo127.0.0.1:27017/mydb-uroot-p123456
# Log in again, only for the user's library login # Although it is Super administrator, but admin can not directly login to other databases, otherwise error #fri A the:Geneva:21.886Error: -{code: -Ok:0.0, ErrMsg:"Auth fails"} at Src/mongo/shell/db.js:228
Show collections
# View link status log in again use the following command to display an error without authorization
Db.system.users.find ();
# View Create user Information
Db.system.users.remove ({User:"Zhansan"})
# Delete User
#恢复密码只需要重启mongodb do not add--auth parameters
MongoDB Login View mode
192.168. 1.5:28017 # HTTP login to view status. /MONGO # Opens the test library after logging in by default. 192.168. 1.5:27017/databaseName # Direct connection to a library does not exist then creating a boot authentication requires specifying the corresponding library to log in
MongoDB View Status
#登录后执行命令查看状态db. RunCommand ({"serverstatus":1})
# indicates how much time (in microseconds) the global write lock consumes the server
# contains the amount of data mapped by the server memory, the virtual memory of the server process, and the occupancy of the Resident memory (MB)
# indicates the number of times the B-tree was retrieved on disk (misses) and memory retrieved (hits). If these two ratios start to rise, consider adding memory.
# How many times did the backstage Fsync and how much time?
# contains the number of each major hit
# count the number of assertions # state information starts from the server start calculation, if too large will be reset, send reset, all counts will be reset, asserts in the Roolovers value increased
MongoDB comes with basic commands
#mongodb自带的命令
. /MONGO Stat
Insert #每秒插入量query #每秒查询量update #每秒更新量delete #每秒删除量locked #锁定量qr|qw #客户端查询排队长度 (Read | Write) ar|aw #活跃客户端量 (Read | WRITE) conn #连接数time #当前时间
MongoDB-Daily Operation II