目录
https://www.mongodb.com/try/download/community
https://www.mongodb.com/download-center/community/releases/archive
将下载的安装包 mongodb-windows-x86_64-4.4.0.zip 解压到安装路径
这里的解压路径是 D:\Hadoop\MongoDB\mongodb-win32-x86_64-windows-4.4.0
添加MONGODB_HOME变量
将MONGODB_HOME变量添加到环境变量
在MongoDB根目录下新建db、log文件夹
初始化数据存储(命令行执行)
mongod --dbpath "D:\Hadoop\MongoDB\mongodb-win32-x86_64-windows-4.4.0\db"
执行之后生成一下文件,然后关闭命令行窗口
在MongoDB根目录下创建配置文件 mongodb.conf
## 端口号(默认27017)
port=27017
## 数据存储路径
dbpath=D:\Hadoop\MongoDB\mongodb-win32-x86_64-windows-4.4.0\db
## 日志存储路径
logpath=D:\Hadoop\MongoDB\mongodb-win32-x86_64-windows-4.4.0\log\mongo.log
## 启用日志文件(默认启用)
journal=true
## 日志是否追加
logappend=true
## 是否过滤无用日志信息(调试模式可改为false)
quiet=true
安装MongoDB服务
mongod --config "D:\Hadoop\MongoDB\mongodb-win32-x86_64-windows-4.4.0\mongodb.conf" --install --serviceName "MongoDB"
1、命令行启动(以管理员身份)
net start MongoDB
net stop MongoDB
2、手动启动
我的电脑 - 管理 - 服务和应用程序 - 服务 - MongoDB
mongo
db
db.help() help on db methods
db.mycoll.help() help on collection methods
sh.help() sharding helpers
rs.help() replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce
show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
show logs show the accessible logger names
show log [name] prints out the last segment of log in memory, 'global' is default
use <db_name> set current database
db.mycoll.find() list objects in collection mycoll
db.mycoll.find( { a : 1 } ) list objects in mycoll where a == 1
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有