无法与MongoDB连接
我与mongo的联系有问题无法与MongoDB连接,mongodb,Mongodb,我与mongo的联系有问题 me@the_host:~$ mongo MongoDB shell version v4.0.0 connecting to: mongodb://127.0.0.1:27017 2018-06-28T17:06:37.445+0200 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Erro
me@the_host:~$ mongo
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-06-28T17:06:37.445+0200 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
我转到/var/log/mongodb/mongod.log
查看:
2018-06-28T17:16:11.763+0200 I COMMAND [initandlisten] Assigning UUID b237b94b-b3a3-4ba1-9c39-c87d6f3555db to collection local.startup_log
2018-06-28T17:16:11.764+0200 F STORAGE [initandlisten] Unable to start up mongod due to missing featureCompatibilityVersion document.
2018-06-28T17:16:11.764+0200 F STORAGE [initandlisten] Please run with --journalOptions 4 to recover the journal. Then run with --repair to restore the document.
2018-06-28T17:16:11.764+0200 F - [initandlisten] Fatal Assertion 40652 at src/mongo/db/repair_database_and_check_version.cpp 555
2018-06-28T17:16:11.764+0200 F - [initandlisten]
我执行了mongod--journalooptions 4
,然后执行了mongod--repair
,但错误仍然是一样的。
我不知道下一步该怎么办
以前克服过这个问题的任何人都能给我指出正确的方向吗?在升级到v4之前你设置了featureCompatibilityVersion吗?@AlexBlex否。最初我从Ubuntu 16.04安装了默认的MongoDB版本,结果是2.7。我清除了它并使用了4.0版,现在我无法连接
mongo
。rm-rf
数据目录(它在配置文件的storage.dbPath中定义)。以前的版本在那里留下了一些残差。然后再次启动mongod。你会丢失所有数据,如果有的话。太好了。它起作用了!