database 如何在 Windows 上启动 mongo db

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29749949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 07:55:20  来源:igfitidea点击:

How to start mongo db on windows

mongodbdatabase

提问by baig772

I am new to mongo, and I am trying to install mongo on my windows system. I am following THIS tutorial, but when I do

我是新手mongo,我正在尝试在我的 Windows 系统上安装 mongo。我正在关注本教程,但是当我这样做时

 C:\mongodb\bin\mongod.exe

my CMDgives me this output

CMD给了我这个输出

2015-04-20T18:53:27.433+0500 I STORAGE  [initandlisten] exception in ini
en: 29 Data directory C:\data\db\ not found., terminating
2015-04-20T18:53:27.436+0500 I CONTROL  [initandlisten] dbexit:  rc: 100

回答by Braj

MongoDB requires a data directory to store all data. MongoDB's default data directory path is \data\db.

MongoDB 需要一个数据目录来存储所有数据。MongoDB 的默认数据目录路径是\data\db.

Create this folder

创建此文件夹

md \data\db

You can specify an alternate path for data files using the --dbpathoption to mongod.exe, for example:

您可以使用--dbpathmongod.exe 选项为数据文件指定备用路径,例如:

C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data

If your path includes spaces, enclose the entire path in double quotes,

如果您的路径包含空格,请将整个路径用双引号括起来,

for example:

例如:

C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"

Read more in detail

详细阅读

回答by Prashanth

I also faced the similar problem on windows, moreover, i dont have my environment variable set so i have to go to bin folder and run mongo. Below are the steps i followed 1) I created a folder on my desktop something like "C:\Desktop\data\"2) In order to use mongo shell, you need to run mongo which is similar to a daemon on unix, so in windows, we can do it by opening a command prompt window and change directory to mongo\bin and run mongod --dbpath C:\Desktop\dataand left it runnning 3) I opened second command prompt window, did a change directory to C:\mongo\bin and executed mongod, that's it

我在 Windows 上也遇到了类似的问题,此外,我没有设置环境变量,所以我必须转到 bin 文件夹并运行 mongo。以下是我遵循的步骤 1) 我在桌面上创建了一个文件夹,例如“C:\Desktop\data\”2) 为了使用 mongo shell,您需要运行类似于 unix 上的守护程序的 mongo,所以在 Windows 中,我们可以通过打开命令提示符窗口并将目录更改为 mongo\bin 并运行 mongod --dbpath C:\Desktop\data并让它运行 3) 我打开第二个命令提示符窗口,将目录更改为C:\mongo\bin 并执行mongod,就是这样

回答by bamossza

Because MongoDB does not know the directory DB.

因为 MongoDB 不知道目录 DB。

Fixed Work for me.

为我固定工作。

Step 1: New Folder e.g. Run cmd

第 1 步:新建文件夹,例如运行 cmd

mkdir  E:\workspace\mongodb\data

Step 2: Move to Root MongoDB path e.g. (cd .../MongoDB/.../bin/)

第 2 步:移动到根 MongoDB 路径,例如 (cd .../MongoDB/.../bin/)

C:\Program Files\MongoDB\Server.4\bin>mongod.exe --dbpath E:\workspace\mongodb\data

Ok.

好的。

回答by Jason

I fixed the same using :

我使用以下方法修复了相同的问题:

Create a folder datain

在文件夹中创建数据

D:\project-workspace\mongodb\data

D:\project-workspace\mongodb\data

Then Create another folder dbinside dataie,

然后在data 中创建另一个文件夹db, 即,

D:\project-workspace\mongodb\data\db

D:\project-workspace\mongodb\data\db

Then run the command

然后运行命令

mongod --dbpath D:\project-workspace\mongodb\data\db

Make sure you have set environment variable for mongodb else browse

确保您已为 mongodb 设置环境变量,否则浏览

C:\Program Files\MongoDB\Server.4\bin
然后执行这个 =>


mongod.exe --dbpath E:\workspace\mongodb\data

回答by Kalyan

Also faced the same issue in windows. if --dbpath directory path does not contain spaces, do not include quotes. Removing quotes, when the path does not have space, resolved the issue.

在 Windows 中也面临同样的问题。如果 --dbpath 目录路径不包含空格,则不要包含引号。删除引号,当路径没有空间时,解决了问题。