mongoDB的安装和配置

获取mongoDB

访问https://www.mongodb.com/download-center,下载最新版本的mongoDB,按照指引一步一步安装即可

配置mongoDB作为windows服务启动

创建一个配置文件

需要创建一个配置文件,配置文件必须设置 systemLog.path系统日志的路径
例如, 在 C:\Program Files\MongoDB\Server\3.6\mongod.cfg 创建一个配置文件,设置systemLog.path 和 storage.dbPath:

systemLog:
    destination: file
    path: c:\data\log\mongod.log
storage:
    dbPath: c:\data\db

作为windows 服务安装

Install the MongoDB service by starting mongod.exe with the --install option and the -config option to specify the previously created configuration file.
安装mongoDB服务通过“mongod.exe” 和 “--install” 选项 和 “--config”选项来使用指定的配置文件安装。
例如:

"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\3.6\mongod.cfg" --install

如果需要的话,还可以安装多个实例 mongod.exe or mongos.exe,但是要为每个服务一个独一无二的名字, --serviceName and --serviceDisplayName.

开始mongoDB服务

net start MongoDB

验证服务是否启动成功了

打开刚才的配置路径下的log文件,如果看到了下面的话 那么成功了!

[initandlisten] waiting for connections on port 27017

链接mongoDB

通过 mongo.exe shell链接

"C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe"

停止

net stop MongoDB

删除

"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --remove
posted @ 2017-12-31 22:49  wtbtbd  阅读(117)  评论(0编辑  收藏  举报