MongoDB快速启动

两种方法:
方式 1 :命令行参数方式启动服务
在 bin 目录中打开命令行提示符,输入如下命令: (mongod --dbpath=..\data\db)

复制代码
mongod --dbpath=..\data\db

方式 2 :配置文件方式启动服务
在解压目录中新建 config 文件夹,该文件夹中新建配置文件 mongod.conf ,内如参考如下:

XML 复制代码
storage:
  #The directory where the mongod instance stores its data.Default Value is "\data\db" on Windows.
  dbPath: D:\02_Server\DBServer\mongodb-win32-x86_64-2008plus-ssl-4.0.1\data 

详细配置项内容可以参考官方文档: https://docs.mongodb.com/manual/reference/configuration-options/
【注意】
1 )配置文件中如果使用双引号,比如路径地址,自动会将双引号的内容转义。如果不转义,则会报错:
error-parsing-yaml-config-file-yaml-cpp-error-at-line-3-column-15-unknown-escape-character-d
解决:
a. 对 \ 换成 / 或 \\
b. 如果路径中没有空格,则无需加引号。
2 )配置文件中不能以 Tab 分割字段 解决:
将其转换成空格。
启动方式:
更多参数配置:

XML 复制代码
systemLog:
    destination: file
#The path of the log file to which mongod or mongos should send all diagnostic logging information
    path: "D:/02_Server/DBServer/mongodb-win32-x86_64-2008plus-ssl-4.0.1/log/mongod.log"
    logAppend: true
storage:
    journal:
        enabled: true
#The directory where the mongod instance stores its data.Default Value is "/data/db".    
        dbPath: "D:/02_Server/DBServer/mongodb-win32-x86_64-2008plus-ssl-4.0.1/data"
    net:
#bindIp: 127.0.0.1
        port: 27017
    setParameter:
        enableLocalhostAuthBypass: false
相关推荐
邓工说电17 分钟前
智慧断路器安全吗?数据加密、离线保护与合规认证全解读
大数据·数据库·人工智能·智能断路器·炜晔科技
adinnet202635 分钟前
企业微调大模型(Fine-tuning):先吃透 RAG 还是先训自己的模型
大数据·数据库
上位机妹子1 小时前
EF Core 两种继承映射:每层次一张表(TPH)与每类型一张表(TPT)
数据库·c#·.netcore·ef core
小马同学-1 小时前
Redis消息队列与客户端编程
数据库·redis
for_ever_love__2 小时前
MySQL 高频面试题 30 问:索引、事务、锁、日志、主从与分库分表(MySQL 8.0 版)
java·数据库·spring boot·mysql·spring cloud·面试·总结
染指11102 小时前
140.Agent-多Agent框架-Agent执行Skills流程
数据库·人工智能·设计模式·langchain·agents
fengkai45452 小时前
十二、Redis -2
运维·数据库·redis·容器
余槐i3 小时前
200万行表加索引锁死写入:PostgreSQL CONCURRENTLY 的三类等待与重建路径
数据库·postgresql·性能优化·索引·explain