Windows環境下安裝MongoDB

1.介紹mongodb

mongodb中有三元素:數據庫,集合,文檔,其中「集合」就是對應關係數據庫中的「表」,「文檔」對應「行」。
偶數爲「穩定版」(如:1.6.X,1.8.X),奇數爲「開發版」(如:1.7.X,1.9.X)數據庫


2.下載與安裝測試

下載地址:https://www.mongodb.com/download-center#atlas命令行

https://www.mongodb.org/dl/win32/x86_64-2008plus-ssl?_ga=2.235777285.58066231.1520499585-1605591877.1520499585日誌

安裝略ssl


3.配置開發

感受默認安裝的位置很差,移動文件夾到D:\MongoDB
新建db目錄、log目錄,新建mongo.config文件
mongo.config內容爲:rem

##數據文件
dbpath=D:\MongoDB\db
##日誌文件
logpath=D:\MongoDB\log\mongo.log文檔


4.啓動服務變量

D:\MongoDB\bin>mongod.exe --config D:\MongoDB\mongo.config


5.客戶端測試

另起一個命令行,啓動客戶端
mongo

不想每次都到cd d:/mongodb/bin下
能夠配置環境變量


新建數據庫student(use dbname,沒有此數據庫就會自動建立)
use student
db.student.insert({"sid":"2012211598","sname":"mengzhang","age":20})
db.student.find()
db.student.find({"sid":"5"})
db.student.remove({"sid":"5"})

db.emp.update({"id":2},{"id":3,"name":"3"})
db.emp.count()


6.中止服務

mongo use admin db.shutdownServer();  

相關文章
相關標籤/搜索