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

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

转载于:https://www.cnblogs.com/wsjun/p/9766350.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值