windows mongodb安装与配置

1. 下载MongoDB安装包;2. 解压到指定目录;3. 创建数据存储目录;4. 配置环境变量;5. 启动MongoDB服务。

MongoDB 4.0在Windows 10下的安装与服务配置教程详解

MongoDB是一个开源的NoSQL数据库,它提供了高性能、高可用性和易扩展性的数据存储解决方案,本文将详细介绍如何在Windows 10操作系统下安装和配置MongoDB 4.0服务。

windows mongodb安装与配置

下载MongoDB 4.0安装包

我们需要从MongoDB官方网站下载适用于Windows 10的MongoDB 4.0安装包,访问以下链接,选择适合您的系统版本的安装包进行下载:

https://www.mongodb.com/try/download/community

安装MongoDB 4.0

1、双击下载好的安装包,启动MongoDB 4.0安装程序。

2、在安装界面中,点击“下一步”按钮。

3、阅读并接受MongoDB软件许可协议,然后点击“下一步”按钮。

4、选择安装类型,对于大多数用户,建议选择“完整”安装类型,以便安装所有MongoDB组件,点击“下一步”按钮。

5、选择安装位置,您可以使用默认的安装位置,也可以点击“浏览”按钮选择其他位置,点击“下一步”按钮。

6、选择需要安装的组件,对于大多数用户,建议保持默认设置,点击“下一步”按钮。

7、在“准备开始”界面,点击“安装”按钮开始安装过程。

8、安装完成后,点击“完成”按钮退出安装程序。

windows mongodb安装与配置

配置MongoDB服务

1、打开Windows资源管理器,导航到MongoDB的安装目录(C:Program FilesMongoDBServer4.0)。

2、在该目录下找到并运行mongod.exe文件,启动MongoDB服务,您也可以将此文件创建快捷方式并将其放置在桌面或开始菜单中,以便以后快速启动。

3、打开命令提示符(按Win + R键,输入cmd,然后按Enter键),输入以下命令以连接到MongoDB服务:

mongo host localhost port 27017

如果连接成功,您将看到类似以下的输出:

MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("a9e9b6c8f9e64c3aa5e8b3e5c6a9e9b6") }
MongoDB server version: 4.0.0
Server has startup warnings: 20220101T00:00:00.0Z
StartupWarnings 
The default storage engine 'wiredTiger' will be used for the database 'admin' by default in a future release (targeting major version >= 4). See https://docs.mongodb.com/manual/administration/storageengines/#storageengines for more information about WiredTiger and its deprecation timeline. To disable this warning, start the server with storageEngine=mmapv1 or noStorageEngine specified. See https://docs.mongodb.com/manual/administration/productionnotes/#startingmongodbwithstorageEngine for additional details on the 'storageEngine' startup option.
20220101T00:00:00.0Z The global replication group 'local' is configured with a priority of 1, but this replica set member does not have any data bearing members in common with other members in the set, which may result in an increased likelihood of network partitioning when running a distributed system with multiple data centers or geographic locations. For more information on configuring a multidatacenter deployment, see https://docs.mongodb.com/manual/tutorial/deployreplicaset/#configureamultidatacenterdeployment. See http://dochub.mongodb.org/core/4.0dev/reference/configurationoptions.html for additional configuration options that may be relevant to your deployment scenario.
20220101T00:00:00.0Z The server will automatically repair ObjectIds using the ObjectId generator in the background, so you do not need to run db.getSiblingDB('admin').runCommand({ repairDatabase: 1 }) to trigger this process manually during startup if you are running a version of mongod older than 4.4. See https://docs.mongodb.com/manual/reference/method/db.getSiblingDB/#dbgetsiblingdbobject for more information about the ObjectId repair process and how to manage it manually if needed. If you would like to disable automatic repair, start the server with noObjectIdRepair or specify a custom ObjectId generation function using the objectidGenerationFunction option (see https://docs.mongodb.com/manual/reference/configurationoptions/#objectidgenerationfunction). To learn more about the changes in this release, see https://docs.mongodb.com/manual/releasenotes/4.0/#changesinthisrelease.EndStartupWarnings 

常见问题与解答

问题1:如何停止MongoDB服务?

答:在命令提示符中输入以下命令:

net stop mongod

或者在任务管理器中找到名为“mongod”的服务,右键单击并选择“停止”。

问题2:如何卸载MongoDB?

答:打开控制面板,找到并卸载“MongoDB Community Edition”程序,请确保删除MongoDB的安装目录(C:Program FilesMongoDBServer4.0)。

问题3:如何升级MongoDB到最新版本?

windows mongodb安装与配置

答:访问MongoDB官方网站(https://www.mongodb.com/try/download/community),下载最新版本的安装包并按照本文中的步骤进行安装和配置,请注意,升级前务必备份您的数据。

问题4:如何在Windows系统中配置环境变量?

答:在Windows系统中配置环境变量的方法如下:

1、右键单击“计算机”图标,选择“属性”。

2、在左侧菜单中选择“高级系统设置”。

3、在“系统属性”窗口中,点击“环境变量”按钮。

4、在“环境变量”窗口中,可以编辑系统变量和用户变量,要为所有用户添加环境变量,请编辑系统变量;要仅为当前用户添加环境变量,请编辑用户变量。

原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/502610.html

(0)
K-seoK-seoSEO优化员
上一篇 2024年5月20日 22:03
下一篇 2024年5月20日 22:05

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

免备案 高防CDN 无视CC/DDOS攻击 限时秒杀,10元即可体验  (专业解决各类攻击)>>点击进入