如何将json文件存入本地MongoDB

前言

MongoDB是目前非常热门的非关系型数据库。其中的数据格式为json,可以直接使用node进行读写,因此MongoDB在全栈开发中,受到很多人的青睐。MongoDB导入数据的方法主要有两种,一种为使用mongo shell的query将数据传入数据库;另一种为使用简单的javascript程序,连接至数据库并且进行导入。

Mongo Shell

首先我们需要启动本地的数据库连接
输入指令

mongod

接着打开mongo shell,在另一个terminal或cmd中输入

mongo

对应的,命令行中会出现

MongoDB shell version v4.0.6
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session {
    "id" : UUID("80092a7b-2c07-4cd6-9fb0-b2f86938adb2") }
MongoDB server version: 4.0.6
---
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.enableFre
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值