LoginSignup
4
5

More than 5 years have passed since last update.

Homebrew で Mac に MongDB をインストールする手順メモ

Posted at

前提環境

  • OS:Mac OS X 10.9.5
  • Homebrew:0.9.5

もし Homebrew がはいってなければ、公式ページどおり、次のようにインストールします。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
※ 執筆時とコマンド内容が変わってるかもしれないので、公式ページを確認ください。
※ 事前に Xcode のインストール(および起動して許諾への同意)が必要かも。もしくはコンパイルできる環境。

手順

といっても brew コマンドで一発。

$ brew install mongodb

バージョンを確認してみます。

$ mongo --version

MongoDB shell version: 2.6.5

MongoDB の起動

MongDBの設定ファイルは /usr/local/etc/mongod.conf にあります。このファイルの中に dbPath が定義されているので、MongoDB を起動する場合は、このパスを指定して起動します。

mongod --dbpath /usr/local/var/mongodb

ターミナルに表示される起動ログに、ポート番号が記載されています。デフォルトは 27017 みたい。

MongoDB への接続

MongoDB が起動している状態で、

$ mongo

プロンプトが > になるので、これで各種のコマンドを叩けます。試しにデータベースの一覧を表示するには、次のようにします。

> show dbs;

おしまい。

4
5
0

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
4
5