mongodb 如何从 Windows 启动 Mongo DB?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20796714/
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
How do I start Mongo DB from Windows?
提问by user3095838
I have installed MongoDB on my Windows 7 (64 bit) machine. I have created the path data/db too but when I tried to start mongodb using the command 'C:\mongodb\bin\mongod.exe'
, it is not starting. It is showing admin web console waiting for connections on port 28017
.
我已经在我的 Windows 7(64 位)机器上安装了 MongoDB。我也创建了路径 data/db 但是当我尝试使用命令启动 mongodb 时'C:\mongodb\bin\mongod.exe'
,它没有启动。它正在显示admin web console waiting for connections on port 28017
。
Help me in starting the MongoDB. And also please suggest if any GUI is available for MongoDB.
帮助我启动 MongoDB。还请建议是否有任何可用于 MongoDB 的 GUI。
回答by xameeramir
Step 1
第1步
Download the mongodb
下载mongodb
Step 2
第2步
- Follow normalsetup instructions
- 遵循正常的设置说明
Step 3
第 3 步
- Create the following folder
- 创建以下文件夹
C:\data\db
C:\data\db
Step 4
第四步
cd
toC:\Program Files\MongoDB\Server\3.2\bin>
- enter command
mongod
- by default, mongodb server will start at port
27017
cd
到C:\Program Files\MongoDB\Server\3.2\bin>
- 输入命令
mongod
- 默认情况下,mongodb 服务器将在端口启动
27017
Step 5
第 5 步
- (optionally) download RoboMongoand follow normalsetup instructions
- (可选)下载RoboMongo并按照正常的设置说明进行操作
Step 6
第 6 步
- Start RoboMongo and create a new connection on
localhost:27017
- 启动 RoboMongo 并在
localhost:27017
Your mongodb is started and connected with RoboMongo - a third party GUI tool
您的 mongodb 已启动并与 RoboMongo(第三方 GUI 工具)连接
回答by Ar maj
This worked for me
这对我有用
mongod --port 27017 --dbpath C:\MongoDB\data\db
回答by Satishakumar Awati
- Download from http://www.mongodb.org/downloads
- Install .msifile in folder C:\mongodb
- Create data, data\db, logdirectories and mongo.configfile under C:\mongodb.
Add the following lines in "mongo.config" file
port=27017 dbpath=C:\mongodb\data\db\ logpath=C:\mongodb\log\mongo.log
Start server :
mongod.exe --config="C:\mongodb\mongo.config"
Connect to localhost MongoDB server via command line
mongo --port 27017
Connect to remote MongoDB server via command line with authentication.
mongo --username abcd --password abc123 --host server_ip_or_dns --port 27017
- 从http://www.mongodb.org/downloads下载
- 在文件夹C:\mongodb 中安装.msi文件
- 在C:\mongodb下创建data、data\db、log目录和mongo.config文件。
在“ mongo.config”文件中添加以下几行
port=27017 dbpath=C:\mongodb\data\db\ logpath=C:\mongodb\log\mongo.log
启动服务器:
mongod.exe --config="C:\mongodb\mongo.config"
通过命令行连接到 localhost MongoDB 服务器
mongo --port 27017
通过带有身份验证的命令行连接到远程 MongoDB 服务器。
mongo --username abcd --password abc123 --host server_ip_or_dns --port 27017
That's it !!!
就是这样 !!!
回答by Vinay Jaju
Step 1: First download the .msi i.e is the installation file from
步骤 1:首先下载 .msi 即安装文件来自
https://www.mongodb.org/downloads#production
https://www.mongodb.org/downloads#production
Step 2: Perform the installation using the so downloaded .msi file.Automatically it gets stored in program files. You could perform a custom installation and change the directory.
第 2 步:使用如此下载的 .msi 文件执行安装。它会自动存储在程序文件中。您可以执行自定义安装并更改目录。
After this you should be able to see a Mongodb folder
在此之后,您应该能够看到一个 Mongodb 文件夹
Step 3: Create a new folder in this Mongodb folder with name 'data'. Create another new folder in your data directory with the name 'db'.
第 3 步:在此 Mongodb 文件夹中创建一个名为“data”的新文件夹。在您的数据目录中创建另一个名为“db”的新文件夹。
Step 4: Open cmd. Go to the directory where your mongodb folder exists and go to a path like C:\MongoDB\Server\3.0\bin. In the bin folder you should have mongodb.exe
第四步:打开cmd。转到 mongodb 文件夹所在的目录,然后转到类似 C:\MongoDB\Server\3.0\bin 的路径。在 bin 文件夹中你应该有 mongodb.exe
Step 5: Now use
第 5 步:现在使用
mongod --port 27017 --dbpath "C:\MongoDB\data\db"
回答by Soham Krishna Paul
Create MongoDB Service in Windows. First Open cmd with administrator
在 Windows 中创建 MongoDB 服务。首先用管理员打开cmd
mongod --port 27017 --dbpath "a mongodb storage actual path e.g: d:\mongo_storage\data" --logpath="a log path e.g: d:\mongo_storage\log\log.txt" --install --serviceName "MongoDB"
After that
在那之后
Start Service
启动服务
net start MongoDB
Stop Service
停止服务
net stop MongoDB
回答by CoderSpeed
there are 2 ways start mongoDB Install location ( ex : C:/ )
有 2 种方式启动 mongoDB 安装位置(例如:C:/)
first of all : copy mongoDB install folder into C:/ location then changed name to "mongodb" or something what u want. here is ex with "mongodb" name
首先:将 mongoDB 安装文件夹复制到 C:/ 位置,然后将名称更改为“mongodb”或您想要的名称。这是带有“mongodb”名称的前任
1 : setup mongoDB is an windows service
1:设置mongoDB是一个windows服务
1.1 : Make directory name "data" in C:/ ( so we have C:/data ),after that make directory "C:/data/db" <br>
1.2 : run in CMD ( Run as Admin) command -> "echo logpath=C:/mongodb/log/mongo.log > C:/mongodb/mongodb.cfg" <br>
1.3 : run in CMD (Run as Adin) command -> "C:/mongodb/bin/mongod.exe --config C:/mongodb/mongod.cfg --install" <br>
1.4 : run command "net start MongoDB" <br>
2: a small .BAT file to start mongoDB without install copy and paste to notepad and save file with filetype ".bat" here is it :
2:一个小的 .BAT 文件来启动 mongoDB 无需安装复制并粘贴到记事本并保存文件类型为“.bat”的文件是这样的:
C:\mongodb\bin\mongod.exe –dbpath=C:/mongodb/data/db
PAUSE
if you getting error 1078 or 1087 lets remove all data in C:/data/db and restart mongoDB ( copy old data to new folder and back it up after restart mongoDB )
如果您收到错误 1078 或 1087,请删除 C:/data/db 中的所有数据并重新启动 mongoDB(将旧数据复制到新文件夹并在重新启动 mongoDB 后备份)
3 . GUI for mongoDB
3 . mongoDB 的图形用户界面
i'm using rockmongo
我正在使用rockmongo
have fun with it
玩得开心
回答by TechDog
I have followed the below steps...May be it will work for you
我已按照以下步骤操作...可能对您有用
Create directory like below
创建如下目录
C:\DATA\DB
C:\数据\数据库
mongod --port 27017 --dbpath "C:\data\db"
It worked for me....
它对我有用......
回答by VipinKundal
It is properly written over here
这里写得恰到好处
If you download the .msi file then install it and if you download the zip file then extract it.
如果您下载 .msi 文件,则安装它,如果您下载 zip 文件,则将其解压缩。
Set up the MongoDB environment.
设置 MongoDB 环境。
MongoDB requires a data directory to store all data. MongoDB's default data directory path is \data\db. Create this folderusing the following commands from a Command Prompt:
MongoDB 需要一个数据目录来存储所有数据。MongoDB 的默认数据目录路径是\data\db。从命令提示符使用以下命令创建此文件夹:
md \data\db
md \data\db
You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:
您可以使用 mongod.exe 的 --dbpath 选项为数据文件指定备用路径,例如:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
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"
C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"
You may also specify the dbpath in a configuration file.
您还可以在配置文件中指定 dbpath。
Start MongoDB.
启动 MongoDB。
To start MongoDB, run mongod.exe. For example, from the Command Prompt:
要启动 MongoDB,请运行 mongod.exe。例如,从命令提示符:
C:\mongodb\bin\mongod.exe
C:\mongodb\bin\mongod.exe
Connect to MongoDB.
连接到 MongoDB。
To connect to MongoDB through the mongo.exe shell, open another Command Prompt.
要通过 mongo.exe shell 连接到 MongoDB,请打开另一个命令提示符。
C:\mongodb\bin\mongo.exe
C:\mongodb\bin\mongo.exe
回答by Zub
Installing MongoDB on Windows is a bit tricky compared to other Executable files... Got a good reference after long search I got Installing MongoDB in Windows
与其他可执行文件相比,在 Windows 上安装 MongoDB 有点棘手......经过长时间搜索后得到了很好的参考我得到了在 Windows 中安装 MongoDB
After Installing open command prompt and type "mongod", then keep the window minimized and open another command prompt window and type "mongo" and you will find the success message of connecting to the test database.
安装完成后打开命令提示符输入“mongod”,然后保持窗口最小化,打开另一个命令提示符窗口并输入“mongo”,你会看到连接到测试数据库的成功信息。
hope it helps
希望能帮助到你
回答by 4J41
It is showing admin web console waiting for connections on port 28017.
It is showing admin web console waiting for connections on port 28017.
The above message means that mongodb has started successfully and is listening on port 28017.
以上信息表示mongodb已经启动成功,正在监听28017端口。
You can use the mongo shell(mongo.exe
) to connect to the mongoDB and perform db operations.
您可以使用 mongo shell( mongo.exe
) 连接到 mongoDB 并执行数据库操作。
There are several GUI tools available for MongoDB like MongoVUE, etc.
有几种可用于 MongoDB 的 GUI 工具,如 MongoVUE 等。