新安装MEAN后Mongo没有运行

时间:2017-04-03 16:37:39

标签: mongodb mean-stack

我是MEAN堆栈的新手,所以我正在阅读官方文档:learn.mean.io,在按照安装Mongo,npm,gulp等的基本步骤后,我用gulp运行应用程序后,我得到以下错误:

错误:首次连接时无法连接到服务器[localhost:27017] [MongoError:connect ECONNREFUSED 127.0.0.1:27017]

当然这与mongo没有在特定端口上运行有关,我可以单独下载mongo并运行它,但是MEAN不应该这样做吗?

2 个答案:

答案 0 :(得分:1)

我猜你没有运行mongod服务器..应用程序只会创建连接。使用ip和端口.. Mongo Db你必须单独设置

答案 1 :(得分:0)

安装Mongo DB和其他工具以设置MEAN Stack后,您需要使用命令提示符启动Mongo数据库服务器。

假设我将Mongo DB安装在一个名为" Projects"的文件夹中。在本地磁盘中:D和I在磁盘D本身有两个名为Data和db的文件夹,如下所示

D://Projects/mongodb
D://Data/db

1. Open Command Prompt ( CMD )
2. Browse to the folder in which Mongo DB is installed.
3. Create a folder named "Data" and inside Data, another folder named "db". this should reside in the local disk where Mongo DB is installed.
4. To run mongodb server, open CMD in the mongodb installed folder and type "mongod --dbpath=" with your respective path.
5. as per my config: mongod --dbpath=d:/data/db ( i have my data & db folder outside of projects folder )
6. this should start the server with a message, "waiting for connections on port: 27017"
7. after starting the server, you may launch your app or mongo shell to connect to the mongodb server.

在配置文件中,您可以添加路径,以便在启动服务器时无需一直指定它。