win10下,安裝moogose環境
阿新 • • 發佈:2018-11-11
第一步:下載moogose安裝包
moogose官方下載
第二步:測試是否啟動了moogose
以管理員身份開啟命令列,cd 到安裝目錄的 bin 資料夾下
F:\MongoDB\Server\4.0\bin>net start mongodb
請求的服務已經啟動。
請鍵入 NET HELPMSG 2182 以獲得更多的幫助。
開啟瀏覽器,搜尋
http://localhost:27017/
頁面顯示:
It looks like you are trying to access MongoDB over HTTP on the native driver port.
第四步:建立資料庫
以管理員身份開啟命令列,cd 到安裝目錄的 bin 資料夾下
F:\MongoDB\Server\4.0\bin>mongo > show dbs admin 0.000GB config 0.000GB local 0.000GB > use happy_come_healthy switched to db happy_come_healthy > db.createCollection('happy_come_healthy') { "ok" : 1 } > show dbs admin 0.000GB config 0.000GB happy_come_healthy 0.000GB local 0.000GB >
注意:當你使用“use happy_come_healthy”切換到名為happy_come_healthy的資料庫時,實際上什麼也沒發生,只有當你呼叫了db.createCollection之後,新的資料庫才被儲存,然後你使用“show dbs”就可以看到新建的庫。
刪除資料庫
刪除資料庫需要切換到指定的庫,然後呼叫dropDatabase()。如下:
> show dbs admin 0.000GB config 0.000GB happy_come_healthy 0.000GB local 0.000GB > use happy_come_healthy switched to db happy_come_healthy > db.dropDatabase() { "dropped" : "happy_come_healthy", "ok" : 1 } > show dbs admin 0.000GB config 0.000GB local 0.000GB >
參考資料:
Node.js開發入門——MongoDB與Mongoose
MongoDB4.0在windows下的安裝與服務配置