美文网首页
Windows 7 安装 Mongodb

Windows 7 安装 Mongodb

作者: 丹丹十个胆小鬼 | 来源:发表于2018-11-02 14:01 被阅读0次

    1、下载免费版本的MongoDB

    下载mongodb压缩包(官方下载地址:https://www.mongodb.com/download-center#community),下载后解压。如下

    mongodb压缩包.png
    在D:\MongoDB中手动创建两个空文件夹
    D:\MongoDB\data\db
    D:\MongoDB\log

    2、启动服务器

    C:\Users\user>D:
    
    D:\>cd MongoDB
    
    D:\MongoDB>cd bin
    
    D:\MongoDB\bin>mongod --dbpath D:\MongoDB\data
    2018-11-02T09:54:36.522+0800 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabled
    Protocols 'none'
    2018-11-02T09:54:36.861+0800 I CONTROL  [initandlisten] MongoDB starting : pid=9104 port=27017 dbpath=D:\MongoDB\data 64-bit
    host=BG02426
    2018-11-02T09:54:36.861+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
    2018-11-02T09:54:36.861+0800 I CONTROL  [initandlisten] db version v4.0.3
    2018-11-02T09:54:36.861+0800 I CONTROL  [initandlisten] git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
    .....
    

    3、连接

    D:\MongoDB\bin>mongo
    MongoDB shell version v4.0.3
    connecting to: mongodb://127.0.0.1:27017
    Implicit session: session { "id" : UUID("705e8266-2305-4ff6-89a7-41a666815e1e") }
    MongoDB server version: 4.0.3
    Welcome to the MongoDB shell.
    For interactive help, type "help".
    For more comprehensive documentation, see
            http://docs.mongodb.org/
    Questions? Try the support group
            http://groups.google.com/group/mongodb-user
    Server has startup warnings:
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten]
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrest
    ricted.
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten]
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
    
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify whic
    h IP
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_
    ip_all to
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, star
    t the
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten]
    2018-11-02T10:11:44.799+0800 I CONTROL  [initandlisten] Hotfix KB2731284 or later update is not installed, will zero-out data
     files.
    2018-11-02T10:11:44.800+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、MongoDB作为windows服务启动

    以上启动服务器只是在当前会话中启动,当关闭终端时,服务器即会关闭,可以将MongoDB作为windows服务启动(开机启动)。

    D:\MongoDB\bin>mongod --dbpath D:\MongoDB\data\db --logpath=D:\MongoDB\log\mongodb.log --logappend --install --serviceName "MongoDB"
    

    在任务管理器中也能看到名为MongoDB服务


    MongoDB服务.png

    现在也可以通过mongo指令去连接服务器了。

    5、添加环境变量

    为了在其他目录也能运行MongoDB,需要添加环境变量:


    添加MongoDB环境变量.png

    5、图形化工具的使用

    图形化工具Robo 3T.png

    相关文章

      网友评论

          本文标题:Windows 7 安装 Mongodb

          本文链接:https://www.haomeiwen.com/subject/woeqxqtx.html