1:基本操作
use admin
db.createUser({user:"lxc",pwd:"123456",roles:['root']})
修改密碼
db.changeUserPassword("username","newpassword")
查看用戶信息
db.runCommand({userInfo:"kangw"})
驗證用戶
db.auth("username","pwd")
創建索引 db.users.ensureIndex({name:1}) db.users.ensureIndex( { "user_id" : 1, "person" : 1 } );
刪除索引 db.users.dropIndexes("user_id")
插入記錄 db.users.insert({a:1, b:1})
條件查詢 db.users.find({'age':{gt:33,gt:33,lte:40}})
獲取表記錄數 Db.users.count()
刪除記錄 db.users.remove({z:'abc'}) 清空表 db.users.remove({})
刪除表 db.users.drop()
創建表 ?db.createCollection("email_content");
顯示表 show collections?
導出數據庫 mongorestore -h 127.0.0.1 -d mongotest -u mongotest -p mongotest1qaz --dir /home/www/mongorestore-2017-04-06/mongotest
導入數據庫 mongorestore -h 127.0.0.1 -d mongotest -u mongotest-p mongotest1qaz --dir /home/www/mongorestore-2017-04-06/mongotest?
2:數據庫配置主要事項:
? ?1):縮進格式要統一不能亂寫;