We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mongodb下载地址:mongodb
下载后直接点击next,可以点击custom选项自定义安装目录,我的安装目录是在F:\mongoDB
F:\mongoDB
目录结构:
安装完成时没有data和mongod.cfg,这是后续需要自己新建
data
mongod.cfg
在安装的根目录下(跟bin同级)新建文件夹data,在data文件夹下新建db文件夹用作为数据库目录 我的目录:F:\mongoDB\data\db
db
F:\mongoDB\data\db
进入bin目录下F:\mongoDB\bin打开cmd输入mongod --dbpath F:\mongoDB\data\db, 在数据库目录db下启动mongodb服务
F:\mongoDB\bin
cmd
mongod --dbpath F:\mongoDB\data\db
启动成功后在浏览器中输入http://localhost:27017/默认端口号(27017) 表明服务启动成功
http://localhost:27017/
如果不想只在F:\mongoDB\bin下启动服务,需要配置环境变量, 我的电脑 - 属性 - 高级系统设置 - 环境变量 中用户变量path新建环境变量F:\mongoDB\bin, 这样我们可以在任何目录下输入mongod --dbpath F:\mongoDB\data\db启动服务
我的电脑
属性
高级系统设置
环境变量
path
之前我们都是通过mongod --dbpath F:\mongoDB\data\db启动服务,我们将MongoDB设置为系统服务,这样就可以不需要每次都手动启动
F:\mongoDB\data
log
systemLog: destination: file path: F:\mongoDB\data\log\mongod.log storage: dbPath: F:\mongoDB\data\db
sc.exe create MongoDB binPath= "\"F:\mongoDB\bin\mongod.exe\" --service --config=\"F:\mongoDB\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
如果看到CreateService SUCCESS则表明创建成功,此时因为我已经创建了服务,所有显示失败
CreateService SUCCESS
此时我们进入任务管理器,打开服务,我们会看到mongodb服务,右键启动,设置为自动,这样每次开机都会自动启动mongodb服务 通过net stop MongoDB关闭服务,net start MongoDB开启服务
net stop MongoDB
net start MongoDB
这样我们mongodb服务就启动成功
The text was updated successfully, but these errors were encountered:
No branches or pull requests
安装
下载后直接点击next,可以点击custom选项自定义安装目录,我的安装目录是在
F:\mongoDB
目录结构:

配置
在安装的根目录下(跟bin同级)新建文件夹
data
,在data
文件夹下新建db
文件夹用作为数据库目录我的目录:
F:\mongoDB\data\db
进入bin目录下
F:\mongoDB\bin
打开cmd
输入mongod --dbpath F:\mongoDB\data\db
,在数据库目录
db
下启动mongodb服务启动成功后在浏览器中输入

http://localhost:27017/
默认端口号(27017)表明服务启动成功
将MongoDB设置为系统服务
之前我们都是通过
mongod --dbpath F:\mongoDB\data\db
启动服务,我们将MongoDB设置为系统服务,这样就可以不需要每次都手动启动F:\mongoDB\data
下创建一个log
文件夹F:\mongoDB
目录下(bin同级),git bash新建一个mongod.cfg
文件,输入sc.exe create MongoDB binPath= "\"F:\mongoDB\bin\mongod.exe\" --service --config=\"F:\mongoDB\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
此时我们进入任务管理器,打开服务,我们会看到mongodb服务,右键启动,设置为自动,这样每次开机都会自动启动mongodb服务

通过
net stop MongoDB
关闭服务,net start MongoDB
开启服务The text was updated successfully, but these errors were encountered: