通过pymongo连接时mongo连接失败
我正在使用这个来插入数据:
import pymongo
import sys
def main():
connection = pymongo.Connection("mongodb://localhost", safe=True)
db = connection.m101
people = db.people
person ={'name': 'Barack Obama', 'role':'President',
'address':{'address1': 'The White House',
'street': '1600 Pensylvania Avenue',
'state':'DC',
'city':'Washington'},
'interests':['government', 'basketball', 'the middle east']
}
people.insert(person)
但是当我尝试使用 mongo
命令时,它显示:
Could not connect to server 127.0.0.1:27017 src/mongo
shell mongo.js:91
exception: connection failed
我该怎么办呢?我正在按照他们的教程在做!