MongoDB随手记2——安装db
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MongoDB随手记2——安装db,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5857字,纯文字阅读大概需要9分钟。
内容图文
![MongoDB随手记2——安装db](/upload/InfoBanner/zyjiaocheng/496/b1daafd7baf14f859c1d9d479df7fd3a.jpg)
\data\db
on the drive from which you start MongoDB. Create this folder by running the following command in a Command Prompt:
md \data\db
You can specify an alternate path for data files using the --dbpath
option to mongod.exe
, for example:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in double quotes, for example:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe" --dbpath "d:\test\mongo db data"
You may also specify the dbpath
in a configuration file.
Start MongoDB.
To start MongoDB, run mongod.exe
. For example, from the Command Prompt:
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe"
This starts the main MongoDB database process. The waiting for connections
message in the console output indicates that the mongod.exe
process is running successfully.
Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe
from communicating on networks. All users should select Private Networks, such as my home or work network
and click Allow access
. For additional information on security and MongoDB, please see the Security Documentation.
Connect to MongoDB.
To connect to MongoDB through the mongo.exe
shell, open another Command Prompt.
"C:\Program Files\MongoDB\Server\3.6\bin\mongo.exe"
If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.
4Begin using MongoDB.
To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.
Before deploying MongoDB in a production environment, consider the Production Notes document.
Later, to stop MongoDB, press Control+C
in the terminal where the mongod
instance is running.
Configure a Windows Service for MongoDB Enterprise
1Open an Administrator command prompt.
Press the Win
key, type cmd.exe
, and press Ctrl + Shift + Enter
to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
2Create directories.
Create directories for your database and log files:
mkdir c:\data\db mkdir c:\data\log3
Create a configuration file.
Create a configuration file. The file must set systemLog.path
. Include additional configuration options as appropriate.
For example, create a file at C:\Program Files\MongoDB\Server\3.6\mongod.cfg
that specifies both systemLog.path
and storage.dbPath
:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
4
Install the MongoDB service.
Important
Run all of the following commands in Command Prompt with “Administrative Privileges”.
Install the MongoDB service by starting mongod.exe
with the --install
option and the -config
option to specify the previously created configuration file.
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\3.4\mongod.cfg" --install
To use an alternate dbpath
, specify the path in the configuration file (e.g. C:\mongodb\mongod.cfg
) or on the command line with the --dbpath
option.
If needed, you can install services for multiple instances of mongod.exe
or mongos.exe
. Install each service with a unique --serviceName
and --serviceDisplayName
. Use multiple instances only when sufficient system resources exist and your system design requires it.
Start the MongoDB service.
net start MongoDB
6
Stop or remove the MongoDB service as needed.
To stop the MongoDB service use the following command:
net stop MongoDB
To remove the MongoDB service use the following command:
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove
Manually Create a Windows Service for MongoDB Enterprise
You can set up the MongoDB server as a Windows Service that starts automatically at boot time.
The following procedure assumes you have installed MongoDB using the .msi
installer with the path C:\Program Files\MongoDB\Server\3.4\
.
If you have installed in an alternative directory, you will need to adjust the paths as appropriate.
1Open an Administrator command prompt.
Press the Win
key, type cmd.exe
, and press Ctrl + Shift + Enter
to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
2Create directories.
Create directories for your database and log files:
mkdir c:\data\db mkdir c:\data\log3
Create a configuration file.
Create a configuration file. The file must set systemLog.path
. Include additional configuration options as appropriate.
For example, create a file at C:\Program Files\MongoDB\Server\3.6\mongod.cfg
that specifies both systemLog.path
and storage.dbPath
:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
4
Create the MongoDB service.
Create the MongoDB service.
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.6\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
sc.exe
requires a space between “=” and the configuration values (eg “binPath= “), and a “" to escape double quotes.
If successfully created, the following log message will display:
[SC] CreateService SUCCESS
5
Start the MongoDB service.
net start MongoDB
6
Stop or remove the MongoDB service as needed.
To stop the MongoDB service, use the following command:
net stop MongoDB
To remove the MongoDB service, first stop the service and then run the following command:
sc.exe delete MongoDB
MongoDB随手记2——安装db
标签:storage sharp lin tip plain gui yaml scalar ast
本文系统来源:http://www.cnblogs.com/it-dennis/p/8018335.html
内容总结
以上是互联网集市为您收集整理的MongoDB随手记2——安装db全部内容,希望文章能够帮你解决MongoDB随手记2——安装db所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。