Mac 搭建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  # 启动

猜你喜欢

转载自blog.csdn.net/hymanjack/article/details/80574161