mongodb for windows

---恢复内容开始---

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 MongoDB's 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 }
>
 先写这么多吧。。后期有时间再补。太累了。。。

---恢复内容结束---

posted @ 2018-10-10 14:53  wsjun  阅读(542)  评论(0编辑  收藏  举报