简体   繁体   English

mongo连接拒绝osx

[英]mongo connection refused osx

I'm trying to install mongo. 我正在尝试安装mongo。 I ran the following: 我执行以下操作:

 $sudo chown -R [username] /usr/local
~ $sudo chmod -R u+w /usr/local
~ $brew link mongodb
Linking /usr/local/Cellar/mongodb/3.0.2... 14 symlinks created

I ran mongo and got the following: 我跑了mongo ,得到以下信息:

~ $mongo
MongoDB shell version: 3.0.2
connecting to: test
2015-04-14T09:21:29.095-0400 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-04-14T09:21:29.097-0400 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed

Not sure what to do. 不知道该怎么办。

If you don't specify a db address, 如果您未指定数据库地址,

$ mongo <db-address>

mongo gets lost in the woods. mongo在树林里迷路了。 If you want a mongo shell without a db, 如果您想要一个没有db的mongo shell,

$ mongo -nodb

does the trick. 绝招。

If you're running locally, you probably either didn't specify a port (if the server isn't running on the default port 27107) or you just don't have a server running. 如果在本地运行,则可能未指定端口(如果服务器未在默认端口27107上运行),或者只是没有服务器在运行。 The mongo command starts a shell, not the server. mongo命令启动外壳程序,而不是服务器。 You need to 你需要

$ mongod --dbpath <path to data directory>

to get the server running. 使服务器运行。 Once it's up, 一旦起来,

$ mongo

should run locally with no problems. 应该在本地运行没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM