我在Macbook中使用Spyder4将python与Anaconda Navigator结合使用。 我试图用python创建MongoDB数据库,但我遇到了一个错误,这是我的代码行话。我尝试过更改我的本地主机路径,但从internet获得的路径无效。 我需要帮助来理解这个问题。 下面是我的代码和我得到的错误
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["customers"]
print(mydb.list_collection_names())
ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused, Timeout: 30s,
Topology Description: <TopologyDescription id: 60b12ac2a840595f4d119d65, topology_type:
Single, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None,
error=AutoReconnect('localhost:27017: [Errno 61] Connection refused')
运行此代码时的错误如下所示
我认为localhost路径有问题,但即使尝试了一些来自internet的路径建议,也无法解决问题
目前没有回答
相关问题 更多 >
编程相关推荐