1. 程式人生 > >mongodb for windows

mongodb for windows

rod etc site command objectid bound acc 如果 this

---恢復內容開始---

1,可以去mongodb.com 官網下載mongodb

安裝方法 這裏就不介紹了

2, 在安裝目錄下新增mongod.cfg,內容如下

systemLog:
    destination: file
    path: f:\mongodb\db\log\mongod.log
storage:
    dbPath: f:\data\db

3, 安裝完以後,打開安裝位置的bin目錄,打開命令提示符

輸入mongo 出現一下提示表示成功,如果失敗 在bin目錄下嘗試修復:mongod --repair

如果還是失敗,那麽就是路徑設置有問題,通過重新對路徑的設置解決此問題 mongod --dbpath=f:\mongodb/data/db/

F:\mongodb\db\bin>mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.2
Server has startup warnings:
2018-09-19T20:47:40.889+0800 I CONTROL  [initandlisten]
2018-09-19T20:47:40.891+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-09-19T20:47:40.892+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2018-09-19T20:47:40.893+0800 I CONTROL [initandlisten] 2018-09-19T20:47:40.893+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2018-09-19T20:47:40.894+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this
server. 2018-09-19T20:47:40.897+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 2018-09-19T20:47:40.898+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2018-09-19T20:47:40.900+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2018-09-19T20:47:40.900+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2018-09-19T20:47:40.901+0800 I CONTROL [initandlisten] --- Enable MongoDBs free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() ---

4,這是就可以輸入db 看一下當前操作的數據庫

db.firstdbdemo.insert({x:10})  可以對數據庫增加一條信息
db.firstdbdemo.find()  查看
> db
test
> db.firstdbdemo.insert({x:10})
WriteResult({ "nInserted" : 1 })
> db.firstdbdemo.find()
{ "_id" : ObjectId("5ba2463de89c59c4815018f9"), "x" : 10 }
>
 先寫這麽多吧。。後期有時間再補。太累了。。。

---恢復內容結束---

mongodb for windows