MongoDB基本操作

    xiaoxiao2026-01-05  11

    MongoDB安装 - Windows版本

    MongoDB官网下载地址

    其中Windows版本(2016-08-15)支持以下版本: - Windows Server 2008 R2 64-bit and later, with SSL support - Windows Server 2008 R2 64-bit and later, without SSL support - Windows Vista 32-bit and later, without SSL support - Windows Server 2008 64-bit and later, without SSL support

    本人使用Windows 7 64-bit版本,选择第一个下载

    安装过程

    安装到用户自定义路径下即可

    创建数据目录

    根据用户需求,在相应路径下创建文件夹

    *本人数据目录的路径为: D:\MongoDB\database*

    开启MongoDB服务

    添加环境变量

    在Path中添加MongoDB的安装路径下的bin文件所在路径

    本人MongoDB的bin文件路径为: D:\Program Files\MongoDB\Server\3.2\bin

    启动MongoDB服务

    mongod.exe --dbpath <MongoDB数据目录路径> 例如: mongod.exe --dbpath D:\MongoDB\database

    将MongoDB作为Windows服务运行

    以管理员方式运行

    mongod.exe --bind_ip 127.0.0.1 -logpath "D:\MongoDB\database" --logappend --dbpath "D:\MongoDB\log\mongodb.log" --port 27017 --serviceName "EnvMongoDB" --serviceDisplayName "EnvironmentDB" --install

    其中具体参数如下

    参数描述–bind_ip绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默认本地所有IP–logpath指定MongoDB日志文件,注意是指定文件不是目录–logappend使用追加的方式写日志–dbpath指定数据库路径–port指定服务端口号,默认端口27017–serviceName指定服务名称–serviceDisplayName指定服务名称,有多个mongodb服务时执行–install指定作为一个Windows服务安装
    转载请注明原文地址: https://ju.6miu.com/read-1305668.html
    最新回复(0)