酢ろぐ!

カレーが嫌いなスマートフォンアプリプログラマのブログ。

MongoDBが起動しない

MongoDBをbrewでインストールして起動させる

MongoDBをbrewでインストールした。

$ brew install mongodb

mongoを実行するとデーモンが立ち上がってないのでエラーになる。

$ mongo
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27017
2017-09-12T12:23:22.295+0900 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-09-12T12:23:22.295+0900 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed

ターミナルを立ち上げてデーモンを起動する。

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

最後mongoを実行する。

$ mongo
MongoDB shell version v3.4.7
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.7
Server has startup warnings: 
2017-09-12T12:55:34.138+0900 I CONTROL  [initandlisten] 
2017-09-12T12:55:34.138+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-12T12:55:34.138+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-09-12T12:55:34.138+0900 I CONTROL  [initandlisten] 
2017-09-12T12:55:34.138+0900 I CONTROL  [initandlisten] 
2017-09-12T12:55:34.138+0900 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> 

繋がった。