LoginSignup
7

More than 5 years have passed since last update.

MacにMongoDBをインストールする

Last updated at Posted at 2015-11-01

若干今更ながらMacにMongoDBをインストールしたのでその時の手順をメモ。

環境

Mac:10.10.5(Yosemite)
MongoDB:3.0.7

参考サイト

インストール手順

Homebrewのパッケージをupdate

$ brew update

mongoDBインストール

$ brew install mongodb

MongoDB実行

データ格納用ディレクトリ作成

$ sudo mkdir -p /data/db
$ sudo chown ${ユーザ名} /data/db

起動

通常であればmongodへのパスが通っているはずのため、以下のコマンドで実行可能
$ mongod

パスが通ってない場合はmongodの場所をwhichで確認し、パスを通すかフルパスで実行

/data/db以外のパスをデータ格納用ディレクトリに使う場合

以下のコマンドでディレクトリを指定する
$ mongod --dbpath ${dir path}

終了

Control + Cにて終了させる

設定等

設定ファイル置き場

/usr/local/etc/mongod.conf

クライアント側起動コマンド

mongo

終わりに

SpringでAPI作るにあたって、RDBじゃなくてNoSQLにしたいなーということで
試しにMongoDB入れてみた。
特にそちらの方が向いてるとかではなくて、ただ使いたかったから。手段の目的化。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7