简体   繁体   English

无法连接到本地主机上的 mongodb 服务器

[英]Unable to connect to my mongodb server on local host

When I enter the command to connect 'mongo --host 127.0.0.1:27017' I don't know why I am getting this error, it used to work before.当我输入连接 'mongo --host 127.0.0.1:27017' 的命令时,我不知道为什么会出现此错误,它以前可以正常工作。 Following the M103 Tutorial on MongoDB University遵循 MongoDB 大学的 M103 教程

MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2020-01-26T17:51:23.154+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-01-26T17:51:23.155+0000 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6

Can you check your mongdb service is running or not.您可以检查您的 mongdb 服务是否正在运行。 If yes then can you restart the service and try again.如果是,那么您可以重新启动服务并重试。 Use below command to restart the service使用以下命令重新启动服务

service mongodb restart

Authentication via Kerberos is supported only in (liable to pay costs) MongoDB Enterprise edition, do you use that one?通过 Kerberos 进行身份验证仅在(负责支付费用)MongoDB 企业版中受支持,您使用那个版本吗?

Check whether mongod service is started.检查mongod服务是否启动。

just try: mongo试试吧:mongo

because 27017 is the default因为 27017 是默认值

are you sure your mongod is running?你确定你的 mongod 正在运行吗? if the machine has rebooted then mongod must be relaunched如果机器已重新启动,则必须重新启动 mongod

I got the same error message because mongo could not access my database data path.我收到相同的错误消息,因为 mongo 无法访问我的数据库数据路径。

Mongo log showed this error: Mongo 日志显示此错误:

I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /my_unrecognized_path/data/db not found., terminating

Hope this helps.希望这可以帮助。

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

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