mongo 报错解决办法 connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
输入mongo,报如下错误:root@instance-tbbjrcnc:/# mongoMongoDB shell version v4.0.12connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb2019-08-12T10:40:58.930+0800 E QUERY[js] Error: c...
·
输入mongo,报如下错误:
root@instance-tbbjrcnc:/# mongo
MongoDB shell version v4.0.12
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2019-08-12T10:40:58.930+0800 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:344:17
@(connect):2:6
exception: connect failed
原因是mongo没有启动
解决方式一:
创建目录 /data/db
cd /
mkdir data
cd data
mkdir db
查找到mongo的安装路径
root@instance-tbbjrcnc:/# whereis mongo
mongo: /usr/bin/mongo
然后手动启动mongo
root@instance-tbbjrcnc:/# cd /usr/bin/
root@instance-tbbjrcnc:/usr/bin# sudo ./mongod -dbpath /data/db/
启动成功!
方法二:创建 service 启动,使用命令启动:service mongodb restart
https://blog.csdn.net/cocos2dGirl/article/details/99300471
方法三:
https://stackoverflow.com/questions/45691032/mongod-service-start-exits-with-code-100
参考:https://blog.csdn.net/qq_39729527/article/details/81285405
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献1条内容
所有评论(0)