简体   繁体   English

如何在Windows 10中启动mongodb

[英]How to start mongodb in windows 10

I have installed mongo-db from the Jupyter notebook using !pip install pymongo . 我已经使用!pip install pymongo从Jupyter笔记本安装了mongo-db。

Now how to start mongodb. 现在如何启动mongodb。 Is there any way to start mongodb through Juyter Notebook. 有什么办法可以通过Juyter Notebook启动mongodb。

from pymongo import MongoClient
client = MongoClient()
#print (client)
#client = MongoClient('mongodb://localhost:27017')
db  = client['test-database']
#print (db)
courses = db.courses
#print (courses)
course = {
    'author':'Mak',
    'course':'Data',
    'price': 100,
    'rating':5
    }
result = courses.insert_one(course)

I am getting ServerSelectionTimeoutError Traceback (most recent call last) since there is no mongodb started 由于没有启动mongodb,因此我正在获取ServerSelectionTimeoutError Traceback (most recent call last)

pymongo is a client and you need a server too. pymongo是客户端,您也需要服务器。

From the pymongo tutorial: 从pymongo教程中:

在此处输入图片说明

https://api.mongodb.com/python/current/tutorial.html https://api.mongodb.com/python/current/tutorial.html

Thanks @match 谢谢@match

Install server before using it 使用之前安装服务器

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

go to folder where you installed mongodb 转到安装了mongodb的文件夹

C:\\Program Files\\MongoDB\\Server\\4.0\\bin> C:\\ Program Files \\ MongoDB \\ Server \\ 4.0 \\ bin>

start mongo.exe 启动mongo.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM