Mac 搭建MongoDB环境

本文介绍如何在Mac上使用Homebrew安装MongoDB,并提供详细的步骤指导如何配置MongoDB的数据库文件存放路径及日志文件位置。此外,还介绍了启动MongoDB的方法。

Mac 搭建MongoDB

1.Update Homebrew’s package database.

In a system shell, issue the following command:

brew update

2.Install MongoDB.

You can install MongoDB via brew with several different options. Use one of the following operations:

Install the MongoDB Binaries
To install the MongoDB binaries, issue the following command in a system shell:

brew install mongodb

Install the Latest Development Release of MongoDB
To install the latest development release for use in testing and development, issue the following command in a system shell:

brew install mongodb --devel

3.配置MongoDB

创建数据库文件存放地和log存放地。

mkdir -p ~/Data/MongoDB/db
mkdir -p ~/Data/MongoDB/log
cd ~/Data/MongoDB/log
vim mongo.log

接下来修改mongodb的配置文件:

vim /usr/local/etc/mongod.conf

我的是:

systemLog:
  destination: file
  path: ~/Data/mongoDB/log/mongo.log
  logAppend: true
storage:
  dbPath: ~/Data/mongoDB/db
net:
  bindIp: 127.0.0.1

将上面systemLog的path改成自己的log位置,
将dbPath的位置改成自己db的位置。

4.运行

mongod --config /usr/local/etc/mongod.conf  # 启动
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值