一、下载
下载地址:https://www.mongodb.com/try/download/community
选择要下载的版本,匹配对应的系统
二、安装
选择next
选择next
选择custom
选择安装路径
选择next
不安装MongoDB 可视化工具 MongoDB Compass
选择install
三、使用
在python中的使用
先安装pymongo库
pip install pymongo
python中调用pymongo
import pymongo
# 连接MongoDB
client = pymongo.MongoClient(host='localhost', port=27017)
# 指定数据库
db = client.test
# 指定集合
collection = db.students
# 插入数据
student = {
'id': '1',
'name': 'zhangsan',
'age': 20
}
result = collection.insert_one(student)
print(result)
# 查询数据
result = collection.find_one({'name': 'zhangsan'})
print(result)