zoukankan      html  css  js  c++  java
  • MongoDB(mongodb-win32-x86_64-enterprise-windows-64-4.2.1-signed.msi)下载,启动和插入数据,查询

    下载链接:https://pan.baidu.com/s/19lM5Q-_BaDbjaO1Pj0SbYg&shfl=sharepset

    安装一路Next就行,安装完毕后,进入目录C:Program FilesMongoDBServer4.2in>

    启动控制台,输入

    cd C:Program FilesMongoDBServer4.2in>

    C:Program FilesMongoDBServer4.2in>mongod -dbpath "d:mgdb"

    上面这条命令是让以d:mgdb为数据库文件所在目录启动db服务。

    然后双击mongo.exe启动控制台。

    使用以下命令插入数据并查询:

    MongoDB Enterprise > use testdb
    switched to db testdb
    
    MongoDB Enterprise > db.stats()
    {
            "db" : "testdb",
            "collections" : 0,
            "views" : 0,
            "objects" : 0,
            "avgObjSize" : 0,
            "dataSize" : 0,
            "storageSize" : 0,
            "numExtents" : 0,
            "indexes" : 0,
            "indexSize" : 0,
            "scaleFactor" : 1,
            "fileSize" : 0,
            "fsUsedSize" : 0,
            "fsTotalSize" : 0,
            "ok" : 1
    }
    
    MongoDB Enterprise > db.company.insert({name:"andy",age:20})
    WriteResult({ "nInserted" : 1 })
    MongoDB Enterprise > db.company.find()
    { "_id" : ObjectId("5daeb24ed0866807b20fe9ca"), "name" : "andy", "age" : 20 }
    MongoDB Enterprise >  db.company.insert(
    ...  [
    ... { name:"cindy",age:23},
    ... { name:"douglas",age:34}
    ... ]
    ...  )
    BulkWriteResult({
            "writeErrors" : [ ],
            "writeConcernErrors" : [ ],
            "nInserted" : 2,
            "nUpserted" : 0,
            "nMatched" : 0,
            "nModified" : 0,
            "nRemoved" : 0,
            "upserted" : [ ]
    })
    MongoDB Enterprise > db.company.find()
    { "_id" : ObjectId("5daeb24ed0866807b20fe9ca"), "name" : "andy", "age" : 20 }
    { "_id" : ObjectId("5daeb3e7d0866807b20fe9cb"), "name" : "金兀术", "age" : 28, "sex" : "Male" }
    { "_id" : ObjectId("5daeb4bcd0866807b20fe9cc"), "name" : "cindy", "age" : 23 }
    { "_id" : ObjectId("5daeb4bcd0866807b20fe9cd"), "name" : "douglas", "age" : 34 }
    { "_id" : ObjectId("5daeb4fed0866807b20fe9ce"), "name" : "cindy", "age" : 23 }
    { "_id" : ObjectId("5daeb4fed0866807b20fe9cf"), "name" : "douglas", "age" : 34 }
    { "_id" : ObjectId("5daeb50ed0866807b20fe9d0"), "name" : "cindy", "age" : 23 }
    { "_id" : ObjectId("5daeb50ed0866807b20fe9d1"), "name" : "douglas", "age" : 34 }
    { "_id" : ObjectId("5daeb53fd0866807b20fe9d2"), "name" : "cindy", "age" : 23 }
    { "_id" : ObjectId("5daeb53fd0866807b20fe9d3"), "name" : "douglas", "age" : 34 }
    MongoDB Enterprise >

    --END-- 2019年10月22日16:46:10

  • 相关阅读:
    使用 typeof bar === "object" 来确定 bar 是否是对象的潜在陷阱是什么?
    null和undefined的区别?
    JS中 [] == ![]结果为true,而 {} == !{}却为false
    kaptcha验证码使用
    Java Web应用中获取用户请求相关信息,如:IP地址、操作系统、浏览器等信息
    springboot注解
    算法思想
    数据结构
    springboot设置接口超时
    mybatis动态sql
  • 原文地址:https://www.cnblogs.com/heyang78/p/11720305.html
Copyright © 2011-2022 走看看