当前位置: 代码迷 >> 综合 >> 树莓派学习笔记——树莓派安装mongodb(mongo.js:145错误解决)
  详细解决方案

树莓派学习笔记——树莓派安装mongodb(mongo.js:145错误解决)

热度:2   发布时间:2023-12-17 04:43:27.0

树莓派安装mongodb

安装mongodb,就一句话

pi@raspberrypi:~ $ sudo apt-get install mongodb

但是当我准备使用mongo命令打开时,却报错了,错误如下:

pi@raspberrypi:~ $ sudo mongo
MongoDB shell version: 2.4.14
connecting to: test
Fri Aug 24 14:22:48.856 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed

通过查找资料,获得解决方法为如下,亲测可用:

pi@raspberrypi:~ $ sudo rm /var/lib/mongodb/mongod.lock 
pi@raspberrypi:~ $ sudo service mongodb restart

补充一点,如果使用pymongo调用时报错,如下情况:

pymongo.errors.ConfigurationError: Server at 127.0.0.1:27017 reports wire version 0, but this version of PyMongo requires at least 2 (MongoDB 2.6).

这说明pymongo的版本不匹配,可以安装低版本的pymongo:

pip3 install pymongo==3.2

更多树莓派笔记内容请访问:https://blog.csdn.net/Q_QuanTing/article/details/81843206

  相关解决方案