Install mongodb on mac

1. Go to the official website to download the installation package mongodb-osx-x86_64-3.4.9.tgz version

2. Unzip it and put it in your own folder, for example: /mongodb/mongodb3.4/

3. Create a new data/db under /mongodb/, the location of the mongodb database

4. Authorize the folder sudo chmod -R 777 data

5. Configure the environment variable vi ~/.bash_profile export Mongodb=/Users/xxxx/mongodb3.4/mongodb/bin:$PATH , where xxxx is the username of my machine, source ~/.bash_profile to make the environment variable take effect.

6. Then start mongodb: cd /Users/xxxx/mongodb3.4/mongodb/bin ---> sudo ./mongod --rest The log as shown below appears

2017-11-02T11:28:26.426+0800 I CONTROL  [main] ** WARNING: --rest is specified without --httpinterface,
2017-11-02T11:28:26.426+0800 I CONTROL  [main] **          enabling http interface
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] MongoDB starting : pid=7572 port=27017 dbpath=/data/db 64-bit host=bogon
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] db version v3.4.9
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] allocator: system
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] modules: none
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] build environment:
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten]     distarch: x86_64
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2017-11-02T11:28:26.498+0800 I CONTROL  [initandlisten] options: { net: { http: { RESTInterfaceEnabled: true, enabled: true } } }
2017-11-02T11:28:26.502+0800 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-11-02T11:28:26.502+0800 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2017-11-02T11:28:26.502+0800 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2017-11-02T11:28:26.502+0800 I CONTROL [initandlisten]
now

exiting : 29 Data directory /data/db not found., terminating, it can be seen that mongodb can't find /data/db before creating such a folder, why can't find it, don't rush to execute the command: sudo ./mongod - -dbpath /Users/xxxx/mongodb3.4/data/db Then execute sudo ./mongod --rest, ok starts, no problem

The log is as follows:

2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] MongoDB starting : pid=7808 port=27017 dbpath=/Users/xxxx/mongodb3.4/data/db 64-bit host=bogon
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] db version v3.4.9
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] allocator: system
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] modules: none
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] build environment:
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten]     distarch: x86_64
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2017-11-02T11:35:36.341+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/Users/xxxx/mongodb3.4/data/db" } }
2017-11-02T11:35:36.344+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1536M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),.......



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325854953&siteId=291194637