mongo筆記

1:基本操作

use admin

db.createUser({user:"lxc",pwd:"123456",roles:['root']})

修改密碼

db.changeUserPassword("username","newpassword")

查看用戶信息

db.runCommand({userInfo:"kangw"})

驗證用戶

db.auth("username","pwd")

創(chuàng)建索引 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}})

獲取表記錄數(shù) Db.users.count()

刪除記錄 db.users.remove({z:'abc'}) 清空表 db.users.remove({})

刪除表 db.users.drop()

創(chuàng)建表 ?db.createCollection("email_content");

顯示表 show collections?

導出數(shù)據(jù)庫 mongorestore -h 127.0.0.1 -d mongotest -u mongotest -p mongotest1qaz --dir /home/www/mongorestore-2017-04-06/mongotest

導入數(shù)據(jù)庫 mongorestore -h 127.0.0.1 -d mongotest -u mongotest-p mongotest1qaz --dir /home/www/mongorestore-2017-04-06/mongotest?


2:數(shù)據(jù)庫配置主要事項:

? ?1):縮進格式要統(tǒng)一不能亂寫;

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 姓名:于川皓 學號:16140210089 轉(zhuǎn)載自:https://baike.baidu.com/item/sq...
    道無涯_cc76閱讀 2,043評論 0 2
  • Mongodb 配置選項 通常在mongod.conf中 配置文件 設置了配置文件后啟動時以自定義的配置文件啟動:...
    AkaTBS閱讀 1,145評論 0 6
  • Spring Cloud為開發(fā)人員提供了快速構建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,534評論 19 139
  • 1.創(chuàng)建文件夾 !/bin/sh mkdir -m 777 "%%1" 2.創(chuàng)建文件 !/bin/sh touch...
    BigJeffWang閱讀 10,488評論 3 53
  • show dbs:顯示數(shù)據(jù)庫列表 show collections:顯示當前數(shù)據(jù)庫中的集合(類似關系數(shù)據(jù)庫中的表)...
    Weiliam閱讀 7,560評論 0 2

友情鏈接更多精彩內(nèi)容