gakkie プログラミング 備忘録

tech::expert(現tech camp) 45期



  • Mac OS X Yosemite 10.14.5
  • Homebrew 2.1.6
  • MongoDB shell version v4.0.3

MongoDB ローカルでの実行方法


Install MongoDB Community Edition on OS X — MongoDB Manual 3.4

1. Homebrew をアップデート
$ brew update
2. MongoDB をインストール
$ brew install mongodb


3. プロセスの起動


==> Pouring mongodb-4.0.3_1.mojave.bottle.tar.gz
==> Caveats
To have launchd start mongodb now and restart at login:
  brew services start mongodb
Or, if you don't want/need a background service you can just run:
  mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺  /usr/local/Cellar/mongodb/4.0.3_1: 18 files, 258.1MB

Homebrew Services という機能を使って、再起動後もプロセスが自動起動するように設定するには

$ brew services start mongodb



$ mongod --config /usr/local/etc/mongod.conf


4. mongo コマンドの実行

3 でプロセスを起動した状態で

$ mongo


mba-2:~ name $ mongo
MongoDB shell version v4.0.3
connecting to: mongodb://
Implicit session: session { "id" : UUID("~~~~~") }
MongoDB server version: 4.0.3
Server has startup warnings: 
2019-06-24T21:25:55.930+0900 I CONTROL  [initandlisten] 
2019-06-24T21:25:55.930+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-06-24T21:25:55.930+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-06-24T21:25:55.930+0900 I CONTROL  [initandlisten] 
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB