在Windows和Linux上安装MongoDB
在Windows和Linux上安装MongoDB (Installing MongoDB on Windows and Linux)
In the previous tutorial, we have learnt about Introduction, Overview, Advantages, Features and when to use MongoDB. In this tutorial we will learn how to setup MongoDB in our local machines. We will be covering steps to install MongoDB and related tools on Windows operating system and Linux operating system.
在上一教程中,我们了解了简介,概述,优势,功能以及何时使用MongoDB。 在本教程中,我们将学习如何在本地计算机上设置MongoDB。 我们将介绍在Windows操作系统和Linux操作系统上安装MongoDB和相关工具的步骤。
在Windows上安装MongoDB (Installing MongoDB on Windows)
Installing MongoDB on a Windows machine is very easy. Below are the steps involved in installing the MongoDB:
在Windows计算机上安装MongoDB非常容易。 以下是安装MongoDB涉及的步骤:
- Download MongoDB executable
.msi
file from the site MongoDB Download Centre. Select the latest version for Windows, the Windows Server 2008 R2 is the version if you are on Windows 7, 8 or 10. - 从站点MongoDB下载中心下载MongoDB可执行文件
.msi
文件。 选择Windows的最新版本,如果您使用的是Windows 7、8或10,则为Windows Server 2008 R2。 -
.msi
file to start the installation. Select the option.msi
文件开始安装。 在安装过程中选择选项“ Custom during the installation process, to specify a custom location where you want MongoDB to be installed. By default it is installed in 自定义 ”,以指定要在其上安装MongoDB的自定义位置。 默认情况下,它安装在C:\mongodb
directory.C:\mongodb
目录中。 -
D:\java\mongodb
D:\java\mongodb
安装了MongoDB -
Component .exe
FileServer mongod.exe Router mongos.exe Client mongo.exe 零件 .exe
文件服务器 蒙哥德 路由器 蒙哥斯 客户 蒙哥 -
data\db
. It is best practice to create this directory under the folder where the MongoDB is installed. So let's create a folder nameddata\db
。 最佳实践是在安装MongoDB的文件夹下创建此目录。 因此,让我们在data and one more folder named data文件夹内创建一个名为db inside data的文件夹和一个名为data folder as shown below. db的文件夹,如下所示。 -
log folder to log the MongoDB data transactions. Under the log folder, create a log file 日志文件夹来记录MongoDB数据事务。 在日志文件夹下,创建一个日志文件
FILE_NAME.log
.FILE_NAME.log
。 - bin directory of the MongoDB installed folder.bin目录。
- Execute the command DATA_DIRECTORY_PATH with the path of data directory present inside MongoDB installed folder. On running this command, the below log will be displayed which says that the MongoDB configuration is successful and the server is up and running fine.
- 执行命令数据目录路径替换DATA_DIRECTORY_PATH 。 运行此命令时,将显示以下日志,该日志指示MongoDB配置成功并且服务器已启动且运行良好。
-
bin directory of the MongoDB again, and start the MongoDB client in order to use the database system. Run the command bin目录,然后启动MongoDB客户端以使用数据库系统。 在命令提示符中运行命令
mongo
in Command Prompt and it will get connected to the MongoDB where the default database ismongo
,它将连接到默认数据库为test. test的MongoDB。 - With this, we have successfully installed the MongoDB on the windows environment and we are good to start off with the MongoDB. 这样,我们已经在Windows环境中成功安装了MongoDB,并且很高兴从MongoDB开始。